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?

  • I am not a guru in docker. However, I know for the fact that I would 100% be able to access the logs of the (e.g. LXC) container I want directly from the server it is running on: /var/lib/lxc/rootfs... Maybe something like this would work for you as well: /var/lib/docker/containers/*/*.log – Dmitriy Kupch Nov 5 '18 at 17:50

The message you're seeing from tail is a warning (not an error). It means that tail 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:

# in docker
root@6296bdc3efad:/# stat -f -c %t /
# on a plain ext4 filesystem
$ stat -f -c %t /

The version of coreutils (which includes tail) in Ubuntu 14.04 (trusty) does not recognize overlayfs, 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 using tail -F (capital F) or tail --follow=name (both are equivalent).

From tail(1):

With --follow (-f), tail defaults to following the file descriptor, which means that even if a tail'ed file is renamed, tail will continue to track its end. This default behavior is not desirable when you really want to track the actual name of the file, not the file descriptor (e.g., log rotation). Use --follow=name in that case. That causes tail to track the named file in a way that accommodates renaming, removal and creation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.