The following instructions will allow to run cronjobs in a Docker container using nginx, php 7.2 and Symfony. In order to run multiple services in a container, we'll use supervisord.
Make sure you have Docker installed in your system.
After cloning this repository we can build the docker container by using
docker-compose -f docker.dev.yml up --build Check the cronjob file content
docker exec -ti cron_docker_php cat /etc/cron.d/cronjobs The Symfony Command used for this cron can be found at www/src/Command/SayHelloCommand
By default there's a cronjob that will print a message in a log file every minute. We can check the log
docker exec -ti cron_docker_php cat /var/log/cron.log We'll be using docker exec to connect with the running container
docker exec -ti cron_docker_php bash The file it's placed next to Dockerfile at
docker/php/cronjobs
You can add as many cron jobs as you want. Make sure the php path is right by using which php inside the running container and you leave and empty line after the last cronjob
In this file we'll find all the related actions commented
We can test our web app via http://localhost:8080 is also working