Reputation: 145
I have in my docker file :
RUN apt-get -y install cron
RUN cron
COPY symfony.cron /var/spool/cron/crontabs/www-data
RUN chown www-data:crontab /var/spool/cron/crontabs/www-data
CMD ["start.sh"]
And in my start.sh :
echo "+ start cron service"
service cron start
All good, the problem is that crons are not running, and is strange because when I go to the docker container and I do service cron status
I get [ ok ] cron is running.
so all good. And when I try to execute one command, is executed well. And when I do crontab -u www-data -l
I get the liste with all the crons. So all is good at this point. But the crons are not executed anymore, so I don't understand the problem, maybe some permissions or I don't know. Please help me !!! Thx in advance and sorry for my english.
Any ideas please
Upvotes: 0
Views: 646
Reputation: 159371
You should broadly assume commands like service start
don’t work in Docker. Just run the program you’re trying to run directly. Make sure it starts as a foreground process.
CMD ["crond", "-f"]
(If your main container script runs a service start
command, and that command exits, and the main container script exits, then the container will exit, which isn’t what you want. If service
is backed by systemd or another init system, your container won’t be running that.)
Upvotes: 1