1

OpenSuse Tumbleweed + Docker 17.04. I created /etc/docker/daemon.json with:

{
    "log-driver": "journald",
    "log-opts": {
            "labels": "my_test",
            "env": "os,customer"
    }
}

Then I started docker daemon: systemctl start docker. Checked it: sudo docker info|grep Logg and see journald as current default driver. Also sudo docker inspect -f '{{.HostConfig.LogConfig.Type}}' MY-CONTAINER-ID shows me journald again. Docker was run as

sudo docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup --tmpfs /run/dbus --tmpfs /run/lock --cap-add=ALL MY-CONTAINER

and then I SH-ed to it. In Docker I made several log-messages with:

logger XXX
logger -p local0.notice XXX
# etc...

I'm see these messages in Docker journald with journalctl -n .... And I supposed that I'll find those log-messages in the container ("host OS") too: with journalctl -n ... - nothing. With docker logs MY-CONTAINER-ID - nothing too. I want to log messages from Docker to container ("host") journald. Configuration looks right, but log messages are missing. Would somebody help me - what is wrong with Docker on OpenSuse/with my configuration?

2
  • Hmm, I added -v /dev/log:/dev/log and it seems to work now, so question is - is it dirty hack or Docker documentation lacks this mandatory mount-point?
    – RandomB
    Nov 6, 2017 at 16:15
  • seems that it's workaround only
    – RandomB
    Nov 6, 2017 at 17:20

1 Answer 1

1

docker journald driver captures the stdout and stderr of the container process.

On the other hand, logger command sends a messase to /dev/log.

Edit

It would be nice to do logger -s

6
  • My container process starts by cron, so no stdout/stderr. Loggins happens through Haskell logging library, but without Docker I see log-messages in systemd journal.
    – RandomB
    Nov 8, 2017 at 10:39
  • It depends on your logging library setting. If it is configured to emit a log to journald, use -v /run/systemd/journal/socket:/run/systemd/journal/socket . If it is configured to emit a log to syslog , use -v /dev/log:/dev/log . If it is configured.to emit a log to stderr, docker log driver has to capture it.
    – takaomag
    Nov 8, 2017 at 12:26
  • Seems that -v /dev/log works. But what does log driver journald in this case?! Nothing? First, I supposed that this magic log-driver does all work and I don't need to mount socket or log storage from the host...
    – RandomB
    Nov 8, 2017 at 13:05
  • What docker log driver does is just to capture stdout and stderr of a continered process. No magic! If your containered process emits a log only to syslog, docker log driver captures no log.
    – takaomag
    Nov 8, 2017 at 13:26
  • One suggestion. If your process is haskell, logging-facade-journald may help you, though I do not know haskell well. github.com/sol/logging-facade/blob/master/README.md
    – takaomag
    Nov 8, 2017 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .