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

Your Answer

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

Browse other questions tagged or ask your own question.