This is a similar issue to "tail -f not following log file in Docker container" but I'm not sure if it's the same root cause.
I'm trying to setup a simple cron docker container, and have been testing a bunch of examples that I can find, including this "https://stackoverflow.com/questions/37458287/how-to-run-a-cron-job-inside-a-docker-container".
FROM ubuntu:latest
# Setup cron and scripts...
...
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the command on container startup
CMD cron && tail -f /var/log/cron.log
The problem is that this works and the cron jobs run, but nothing appears in the docker logs or output when running docker run
. And yes, I have verified that the log file is being written to by running a docker exec
command on the container.
I then tested changing from ubuntu:latest
to ubuntu:trusty
, thinking that it might have something to do with Ubuntu 16. This resulted in the following error when starting the container:
tail: unrecognized file system type 0x794c7630 for '/var/log/cron.log'. please report this to bug-coreutils@gnu.org. reverting to polling
After googling that error I found some suggestions. So I tried tweaking my docker file like this:
# RUN touch /var/log/cron.log <-- remove this
CMD touch /var/log/cron.log && cron && tail -f /var/log/cron.log
Now when I run this with ubuntu:latest
and it seems to work just fine. What exactly is going on here?
Best Answer
The message you're seeing from
tail
is a warning (not an error). It means thattail
did not recognize the filesystem, which in this case is an overlayfs configured by docker.You can check the filesystem type using the
stat(1)
command, for example:The version of
coreutils
(which includestail
) in Ubuntu 14.04 (trusty) does not recognizeoverlayfs
, hence the warning. The version in Ubuntu 18.04 (bionic) recognizes it fine, so that's why there's no warning.This warning is not the cause of your problem that the log messages are not appearing as you expect. That's caused by
tail
watching a different file than syslog is writing to. You should be able to resolve that by usingtail -F
(capitalF
) ortail --follow=name
(both are equivalent).From
tail(1)
: