[systemd-devel] Access journal log files within Docker Container using sd-journal API

Lennart Poettering lennart at poettering.net
Tue Mar 9 09:36:11 UTC 2021


On Di, 09.03.21 10:24, Sebastian Borchers (sebastian at desertbit.com) wrote:

> Hello,
>
> I have a question. I am trying to read journald log files within a
> docker container on a host that is using systemd.
> Inside the container, systemd is NOT running. I want to use a library
> that uses the sd-journal API to read the logs within the container.
>
> I tried the following docker cmd:
>
> /docker run --rm --interactive --tty \//
> //        --net host \//
> //        //--privileged \//
> //        //-v /run:/run \//
> //        -v /var:/var \//
> //        --mount type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup \//
> //        --mount type=bind,source=/sys/fs/fuse,target=/sys/fs/fuse \
>         myContainer:latest
> /
>
> When running my code inside this container, though, the log files are
> always empty.
> Running the same code on my host machine correctly yields the log files.

Does "journalctl --file=…" work?


Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list