Closed kundeng closed 6 years ago
That's normal, systemd logs by default to journal and stored as a binary log format.
I've tried to log to stdout/console with --log-target=console
or --default-standard-output=journal+console
, but the problem is known and not yet fixed by moby.
We can get around by executing systemd with a shell and redirect to stdout, but that's ugly.
Furthermore, we will not be able to have logs inside the container with journalctl
.
You mean you tried multiple methods but it didn't work?
Your get-around is something like this: CMD ["/bin/bash", "-c", "exec /sbin/init --log-target=journal 3>&1"]
Yes @kundeng that was exaclty what I was thinking for (apart changing bash
by sh
).
I've seen this initially on https://github.com/solita/docker-systemd/blob/a56a659e099f607df006f6ed89ebb99332ebdab9/Dockerfile#L27.
Thanks to have reported the issue by the way! I will try other options before opting for this one.
This last command fix only for logs of the boot sequence. When we docker exec
on the container, the commands aren't logged.
Even https://github.com/solita/docker-systemd doesn't do it, and recommend using docker exec systemd journalctl
to show system logs.
I won't add this fix because the boot sequence's logs are not really useful, and I haven't found a way to centralize all logs to docker logs
.
OpenRC have also the same problem. I would like to keep the overall simple - just have containers to test if a service works or not.
Hi, I tested the dockerfile for debian 8. For some reason, the docker logs -f containername doesn't show anything. Do you know why?