Mandragor
Mandragor

Reputation: 5604

Get log of a systemd/journald in a docker container to "docker logs"

I am running a systemd in a docker container.

I want to get all the messages logged by jounrnald, when i use

docker logs <containername>

Right now the whole messages goe into the journal in the container and nothing appears when i use "docker logs". How can i turn this off or redirect so that everything appears in docker logs?

Upvotes: 1

Views: 4781

Answers (1)

aceton1k
aceton1k

Reputation: 61

You need to create the container with systemd with tty allocated:

docker run -t ...

Then, inside of the container, edit /etc/systemd/journald.conf file with:

ForwardToConsole=yes

Now just restart systemd-journald inside of the container and you should be good to go:

systemctl restart systemd-journald

Upvotes: 2

Related Questions