So I've been having loads of fun with Docker and Docker-Compose recently, but need the community's advice here. I have a docker-compose file comprised of:
- An Nginx container (based on
nginx:1.12-alpine
image) - A PHP-7.0 FPM container (based on
php:7.0-fpm-alpine
image) - A MySQL container (based on
alpine:3.6
image)
In keeping with Docker's principles of separating processes into individual containers, I would now like to add a fourth container to run Cron. The crontab will be simply:
*/5 * * * * www-data sh /var/www/html/cron.sh
This is for a Magento site, and cron usually requires decent computing power - therefore I figure it would be great to have it in its own container.
I have 3 questions regarding this ...
1) Magento's cron.sh runs a few checks and then runs cron.php, so I assume that my new cron container has to have php installed and running - correct?
2) Assuming that I do need php running in the cron container, then I'm uncertain if I should create a Dockerfile based off the php:7.0-cli-alpine
image or to use an alternative? I've read somewhere that CLI images don't run in daemon mode, so this container may exit immediately after running docker-compose up -d
.
3) Assuming that I am correct on (1) and (2) above, will I need to ensure that any PHP/PECL extensions I've installed in my custom PHP-7.0 FPM image are also installed in this new cron image?
Thank you for time!