Answer the question
In order to leave comments, you need to log in
How to make a bundle in Docker: php + cron?
In Docker, you need to make sure that the php script is run in cron once a day. Can you tell me how to implement it correctly? On the Internet, I met the option to run 2 processes at once in one container via supervisor (fpm and cron), but others say that each process should be isolated. I also met another option, when something in the spirit of docker exec php /path/to/php/script.php is written to the cron in the host system, but this looks a lot like a crutch. I created 2 containers: in one php in another cron. I linked them using links and volumes, but I can't call a php script from another container from the php cron. Tell me how to do it right?
docker-compose.yml file
cron:
build: ./
links:
- "php"
volumes:
- "./:/home"
php:
image: php
command: tail -f /dev/null
volumes:
- "./:/home"
FROM centos
RUN yum -y update
RUN yum -y install crontabs
RUN sed -i -e '/pam_loginuid.so/s/^/#/' /etc/pam.d/crond
ADD cron /etc/cron.d/cron_test
RUN chmod 0644 /etc/cron.d/cron_test
RUN crontab /etc/cron.d/cron_test
CMD crond && tail -f /dev/null
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question