Approach No. 1
Create your custom entrypoint.sh, something like this:
#!/bin/bash
cron -f &
docker-php-entrypoint php-fpm
Pay attention to &, this means "send to the background."
Then:
COPY ./entrypoint.sh /
ENTRYPOINT /entrypoint.sh
Approach # 2
But there is a more complicated installation method supervisor, see docs (daemon manager used in docker):
Docker:
RUN apt-get update
RUN 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
:
docker exec <container-id> supervisorctl status
docker exec <container-id> supervisorctl tail -f php
docker exec <container-id> supervisorctl tail -f cron
docker exec <container-id> supervisorctl restart php