How to get logs from Docker with journald driver?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












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?







share|improve this question




















  • 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?
    – Paul-AG
    Nov 6 '17 at 16:15











  • seems that it's workaround only
    – Paul-AG
    Nov 6 '17 at 17:20














up vote
0
down vote

favorite












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?







share|improve this question




















  • 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?
    – Paul-AG
    Nov 6 '17 at 16:15











  • seems that it's workaround only
    – Paul-AG
    Nov 6 '17 at 17:20












up vote
0
down vote

favorite









up vote
0
down vote

favorite











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?







share|improve this question












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?









share|improve this question











share|improve this question




share|improve this question










asked Nov 6 '17 at 15:34









Paul-AG

101




101











  • 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?
    – Paul-AG
    Nov 6 '17 at 16:15











  • seems that it's workaround only
    – Paul-AG
    Nov 6 '17 at 17:20
















  • 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?
    – Paul-AG
    Nov 6 '17 at 16:15











  • seems that it's workaround only
    – Paul-AG
    Nov 6 '17 at 17:20















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?
– Paul-AG
Nov 6 '17 at 16:15





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?
– Paul-AG
Nov 6 '17 at 16:15













seems that it's workaround only
– Paul-AG
Nov 6 '17 at 17:20




seems that it's workaround only
– Paul-AG
Nov 6 '17 at 17:20










1 Answer
1






active

oldest

votes

















up vote
1
down vote













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






share|improve this answer






















  • 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.
    – Paul-AG
    Nov 8 '17 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 '17 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...
    – Paul-AG
    Nov 8 '17 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 '17 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 '17 at 13:31











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402850%2fhow-to-get-logs-from-docker-with-journald-driver%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













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






share|improve this answer






















  • 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.
    – Paul-AG
    Nov 8 '17 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 '17 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...
    – Paul-AG
    Nov 8 '17 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 '17 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 '17 at 13:31















up vote
1
down vote













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






share|improve this answer






















  • 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.
    – Paul-AG
    Nov 8 '17 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 '17 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...
    – Paul-AG
    Nov 8 '17 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 '17 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 '17 at 13:31













up vote
1
down vote










up vote
1
down vote









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






share|improve this answer














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







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 8 '17 at 12:28

























answered Nov 7 '17 at 11:51









takaomag

1112




1112











  • 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.
    – Paul-AG
    Nov 8 '17 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 '17 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...
    – Paul-AG
    Nov 8 '17 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 '17 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 '17 at 13:31

















  • 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.
    – Paul-AG
    Nov 8 '17 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 '17 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...
    – Paul-AG
    Nov 8 '17 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 '17 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 '17 at 13:31
















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.
– Paul-AG
Nov 8 '17 at 10:39




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.
– Paul-AG
Nov 8 '17 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 '17 at 12:26





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 '17 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...
– Paul-AG
Nov 8 '17 at 13:05




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...
– Paul-AG
Nov 8 '17 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 '17 at 13:26




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 '17 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 '17 at 13:31





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 '17 at 13:31


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402850%2fhow-to-get-logs-from-docker-with-journald-driver%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)