Cronjob in symfony running on docker
I am trying to run a symfony command through cron but it is now executing never. The application is runningin docker and I can’t find information if I need to specify roles or something else. Other standard linux commands are executed successfully but looks like cron doesn’t want to start app/console. Here is my cronjob:
* * * * * /usr/local/bin/php /usr/lib/myApp/app/console myCommand --env=prod >> /usr/lib/myApp/testLog.txt 2>&1
Does anyone have any suggestions how to run symfony command in docker using cron?
One Solution collect form web for “Cronjob in symfony running on docker”
The philosophy of Docker is to have one process per container. That means, you usually have no init system and thus, no services running inside the container, e.g.
There are ways to create your own Docker Image with such an init-system/background service. Images based on Alpine often use S6.
Another solution is to have use the cron-service on your host and rewrite the command to something like
docker exec <container_name> /usr/local/bin/php ...