Bug 1386661 - docker logs useless messages to journald
Summary: docker logs useless messages to journald
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: docker
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-19 12:05 UTC by Jakub Filak
Modified: 2016-12-01 00:50 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-10-19 13:58:58 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jakub Filak 2016-10-19 12:05:49 UTC
Description of problem:
Any command issued in a interactive docker container produces a message in journald like the following one:
Oct 19 13:43:16 photon dockerd-current[3002]: [6B blob data]

and direct logging to journald from the container does not work:
# docker run -it -v /dev/log:/dev/log fedora /usr/bin/bash
# dnf install systemd-python
# python <<< "from systemd import journal; journal.send('journald Hello')"
# logger "Hello"

On host:
Oct 19 13:47:59 photon dockerd-current[3002]: [107B blob data]
Oct 19 13:47:59 photon root[4354]: Hello

Version-Release number of selected component (if applicable):
docker-1.12.2-3.git15c82b8.fc26.x86_64

How reproducible:
Always

Steps to Reproduce:
1. docker run -v /dev/log:/dev/log -it fedora /usr/bin/bash
2. echo "Hello!"
3. dnf install python-systemd
4. python <<< "from systemd import journal; journal.send('journald Hello')"

Actual results:
Oct 19 13:57:50 photon dockerd-current[3002]: [54B blob data]
Oct 19 13:57:50 photon dockerd-current[3002]: [4B blob data]
Oct 19 14:04:22 photon dockerd-current[3002]: [116B blob data]

Expected results:
Oct 19 13:57:50 photon python[3213]: journald Hello

Comment 1 Daniel Walsh 2016-10-19 12:35:18 UTC
docker logs all stdout/stderr to journal, that is by design.  You can specify alternative loggers via the docker run command.

Heck to see if the journald Hello ended up somewhere else.  Not sure what happened to it.  Unless systemd/journald is doing something to drop the message.

Comment 2 Daniel Walsh 2016-10-19 13:58:58 UTC
sh-4.3# python <<< "from systemd import journal; journal.send('journald Hello')"
sh-4.3# logger "journald logger Hello"
sh-4.3# exit
sh-4.3# journalctl -b | grep Hello
Oct 19 09:53:28 dhcp-10-19-62-196.boston.devel.redhat.com root[16787]: journald logger Hello

I think the journal call would send directly to the journal socket.

This works for me.

docker run -ti -v /dev/log:/dev/log -v /var/run/systemd/journal/socket:/var/run/systemd/journal/socket --name journald fedora sh


python <<< "from systemd import journal; journal.send('journald Hello')"
journalctl -b | grep HelloOct 19 09:53:28 dhcp-10-19-62-196.boston.devel.redhat.com root[16787]: journald logger Hello
Oct 19 09:57:51 dhcp-10-19-62-196.boston.devel.redhat.com python[17523]: journald Hello

Comment 3 Daniel Walsh 2016-10-19 14:40:49 UTC
I wrote  a blog on this.  Hopefully will be published on projectatomic.io

https://github.com/projectatomic/atomic-site/issues/367


Note You need to log in before you can comment on or make changes to this bug.