when using journald log-driver, follow logs hangs after container is exited
- [x] This is a bug report
- [ ] This is a feature request
- [x] I searched existing issues before opening this one
Expected behavior
docker logs -f <container-id> should stop when the container exits
Actual behavior
docker logs -f <container-id> hangs after the container has exited.
Steps to reproduce the behavior
Running this command prints out 10 log lines then hangs:
docker logs -f $(docker run -d --rm busybox sh -c "for i in \$(seq 1 10); do echo logline \$i; sleep 1; done")
EDIT: this may be related to journald log driver we use, so reproduction might work better with
docker logs -f $(docker run -d --rm --log-driver journald busybox sh -c "for i in \$(seq 1 10); do echo logline \$i; sleep 1; done")
Output of docker version:
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:57 2018
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:16:44 2018
OS/Arch: linux/amd64
Experimental: false
Output of docker info:
Containers: 145
Running: 90
Paused: 0
Stopped: 55
Images: 27
Server Version: 18.09.0
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-141-generic
Operating System: Ubuntu 16.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 11.73GiB
Name: mgmt
ID: FKMI:HY6O:VDG7:QVKY:SNVU:VMBD:APM4:D6ZJ:BQ22:G5AF:2MGO:PNVM
Docker Root Dir: /data/secure/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
WARNING: No swap limit support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Additional environment details (AWS, VirtualBox, physical, etc.) I only tested this on VMWare ESXi 6.5
Updated the title as apparently this may be related to journald log driver that we use. So on linux the following line should reproduce:
docker logs -f $(docker run -d --rm --log-driver journald busybox sh -c "for i in \$(seq 1 10); do echo logline \$i; sleep 1; done")
I wonder if this is related to moby/moby#27343 ?
Might be a regression since it works on 18.06.1, even while using the journald log driver.
docker info from a host with an older version that works:
Containers: 58
Running: 49
Paused: 0
Stopped: 9
Images: 26
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-138-generic
Operating System: Ubuntu 16.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 31.42GiB
Name: apimdev0159
ID: 6WEK:5CCW:Y3SA:OE7R:3H7F:JDIY:BFJZ:ZQ5Z:S6I7:AS5P:6IVE:GOOJ
Docker Root Dir: /data/secure/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
Just found the same issue while working on fixing journald log driver, and currently have no idea of how to fix it...
Proposed fix: https://github.com/moby/moby/pull/38859
fix : moby/moby#39305