Approach #1
Create your custom entrypoint.sh, something like this:
#!/bin/bash
cron -f &
docker-php-entrypoint php-fpm
Note the &
, it means "send to background".
Then:
COPY ./entrypoint.sh /
ENTRYPOINT /entrypoint.sh
Approach #2
But, there is a more sophisticated way that is installing supervisor
, see docs (a demons manager used in docker):
In Dockerfile:
RUN apt-get update && apt-get install supervisor
COPY ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
...
CMD ["/usr/bin/supervisord"]
supervisord.conf
[program:cron]
command = cron -f
[program:php]
command = docker-php-entrypoint php-fpm
Some troubleshooting commands:
docker exec supervisorctl status
docker exec supervisorctl tail -f php
docker exec supervisorctl tail -f cron
docker exec supervisorctl restart php