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

Sebastian Borchers sebastian at desertbit.com
Tue Mar 9 09:49:21 UTC 2021


Hello,

> Does "journalctl --file=…" work?
You mean inside the container, right?
I installed systemd in the container and tried the following command:

journalctl --file /var/log/journal/<machine-id>/system.journal

and it printed: *Failed to open files: Protocol not supported*

So no, it does indeed not work.


Sebastian

On 09/03/2021 10:36, Lennart Poettering wrote:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210309/1d062770/attachment.htm>


More information about the systemd-devel mailing list