Does the 'core' user have a UID smaller than 1000? If so, the stdout and stderr of the container should go to the system journal, if not, it should get sent to the user's journal, and you should be able to use `journalctl --user` as the 'user' core to read the logs of the rootless container. See this[1] on the Arch wiki.

Also I think that the alpine `logger` command should send its input to syslog (the /dev/log socket), not stdout, and so not end up in the journal.

Joost

[1] https://wiki.archlinux.org/title/systemd/User#Reading_the_journal

------- Original Message -------
On Friday, August 19th, 2022 at 20:29, Ryan Wilson <rdwilson@gmail.com> wrote:

The previous thread about logging was timely as I've been experimenting with a setup to make sure I'm capturing all the logs from a few important containers I've got running. But I'm still having some inconsistencies in what shows up in the logs.

Some of my containers I want to run as root (rootful podman) and some as a user (rootless podman). I'd like to get all of their logs to journald if possible.

This systemd service file runs as a user and works correctly, but doesn't log anything to journald. I can't make it work with "type=forking" (the container starts, but is immediately stopped then killed for some reason):

[Unit]
Description=Hello
After=network-online.target
Wants=network-online.target user-runtime-dir@1000.service

[Service]
Type=simple
User=core
Group=core
TimeoutStartSec=70
ExecStart=/usr/bin/podman run --name hello --replace alpine /bin/sh -c "while true; do date; logger $(date); echo hello; logger hello; sleep 60; done"
ExecStop=/usr/bin/podman stop --ignore hello
ExecStopPost=/usr/bin/podman rm -f --ignore hello

[Install]
WantedBy=multi-user.target


This systemd service file works correctly and logs to journald, but only as root:

[Unit]
Description=Hello
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
TimeoutStartSec=70
ExecStart=/usr/bin/podman run --name hello -d --replace alpine /bin/sh -c "while true; do date; logger $(date); echo hello; logger hello; sleep 60; done"
ExecStop=/usr/bin/podman stop --ignore hello
ExecStopPost=/usr/bin/podman rm -f --ignore hello

[Install]
WantedBy=multi-user.target


How do I make the logging work to journald from rootless podman?

Ryan