Am 09.05.24 um 16:07 schrieb Chris Evich:
On 5/8/24 15:38, Leon Fauster via Podman wrote:
> I wonder whats the current best approach for having the logs of one
> container accumulated at the host layer (journald).
>
> The container runs systemd/journald and is started via a quadlet config
> with LogDriver=passthrough. So, everything that the container spells out
> via stderr/stdout is captured at the host layer.
>
> How to pass everything of the container journald to the host journald?
> I played with LogTarget in /etc/systemd/system.conf without success.
>
> I'd really appreciate any ideas!
>
Are you doing this for rootless podman or rootfull?
I hacked my way through this very thing and eventually got it working
for rootless podman. It required some tricks but sadly I deleted the VM
long ago and don't remember them. I vaguely remember I had to add the
user into a special group on the host.
"LogDriver=passthrough" rings bells for me.
"LogTarget in /etc/systemd/system.conf" also seems familiar.
Sorry I can't remember more. What you're trying is _possible_ though.
The container runs in a rootless podman environment (RHEL9).
I played a bit with " -v /dev/log:/dev/log " and it at least
logs some messages but the log stream in the container is splitted
when doing this way (not all messages are forwarded to the host)
and the content of the logs are not namespaced on the host layer.
What I have now. Container runs with log_driver=journald or when
started via quadlet with log-driver=passthrough. The journald in
the container has following drop-in
$ cat /etc/systemd/journald.conf.d/forward.conf
[Journal]
ForwardToConsole=yes
The host gets namespaced log entries of the container now. It seems
that everything is arriving at the host level.
I'm testing this the first time. So, it seems to work but not sure if
this way is the best practice way ...?
--
Leon