Issue
I run a docker php container to show a website. I'm using the php:5.6-apache image and then in the Dockerfile I put theses lines :
# Setup crontab
ADD ./crontab /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab
RUN touch /var/log/cron.log
CMD cron && tail -f /var/log/cron.log
This works very well, if in the crontab file I put a line to put a hello world in a file, then the process works but I can't access anymore to my website. If i try to write localhost i get a "can't access to the server error" like there is no server running.
If i comment "CMD cron && tail -f /var/log/cron.log", then i can now reach the server but the crontab not work anymore...
What can i do ?
Solution
There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect. (https://docs.docker.com/engine/reference/builder/#cmd)
Your cron CMD removes the one in php:5.6-apache image. You have to use RUN commands for cron as well.
Answered By - Dukecz