Cron running in Docker container may be difficult to troubleshoot without syslog.

In order to troubleshoot why some scheduled Cron jobs are not running we have introduced rsyslog daemon into Docker container and soon enough the following error message appeared in logs:

NUMBER OF HARD LINKS > 1 (/etc/crontab)

The problem originates from layered Docker file system overlay(fs) and Cron's tight security feature refuses to process hard-linked files.

The solution to this problem is trivial: use the following command in container's entry script to unlink cron configuration files:

touch /etc/crontab /etc/cron.*/*

Conclusion

One application per container is often a bad idea especially when application depends on supporting services like Cron. The latter is needlessly difficult to troubleshoot without syslog. Also Cron may benefit from Mail Transfer Agent (MTA) hence running multiple daemons in container is often a necessity and syslog is helpful to save time while troubleshooting problems.

Therefore lightweight init systems like Supervisor or runit are very useful to run multiple services in Docker containers.