tail -f not following log file in Docker container
Solution 1:
Not a solution but a workaround:
I have the same problem on CoreOS 607.0.0 and reproduced this problem in containers based on Ubuntu or Fedora. However containers that use busybox do not have this issue. Two workarounds:
1) use a busybox-based container image such as alpine
2) install busybox in your existing container and run
busybox tail -F <logfile>
Solution 2:
This is a bug introduced in CoreOS 561 when the default file system was changed from btrfs to the overlayfs. I found a workaround to basically format the filesystem using btrfs when a host is first started, and that seems to be working for now.
Include the following in your CloudInit:
#cloud-config
coreos:
units:
- name: format-var-lib-docker.service
command: start
content: |
[Unit]
Before=docker.service var-lib-docker.mount
ConditionPathExists=!/var/lib/docker.btrfs
[Service]
Type=oneshot
ExecStart=/usr/bin/truncate --size=25G /var/lib/docker.btrfs
ExecStart=/usr/sbin/mkfs.btrfs /var/lib/docker.btrfs
- name: var-lib-docker.mount
enable: true
content: |
[Unit]
Before=docker.service
After=format-var-lib-docker.service
Requires=format-var-lib-docker.service
[Install]
RequiredBy=docker.service
[Mount]
What=/var/lib/docker.btrfs
Where=/var/lib/docker
Type=btrfs
Options=loop,discard