Score:0

How can I configure cron startup on a new image without harming the Apache service?

ro flag

I'm creating a new image with cron which is based on the php:7.3-apache-buster image.

The build of the image goes without a hitch. The container is also created with a status of Up. However, in the browser when I type http://localhost:8082 no Apache page is shown. The Apache service is inherited from the php:7.3-apache-buster image.

In my Dockerfile the last line is CMD cron && tail -f /var/log/cron.log. I believe it is this line that generates the problem.

If I enter the container with the command docker exec -it cont-mysite-01 /bin/bash and run the command service apache2 start, Apache starts normally.

What am I not understanding?

How can I build an image where the Apache from the base image and the Cron from the new image work together?

My references:

https://github.com/Ekito/docker-cron/blob/master/Dockerfile

https://hub.docker.com/_/php

Score:0
ro flag

I solved the problem as follows:

I removed the line CMD cron && tail -f /var/log/cron.log from the Dockerfile.

Then I added the line RUN sed -i 's/^exec /service cron start\n\nexec /' /usr/local/bin/apache2-foreground.

After creating the container with the image run the commands to check Apache2 and Cron:

docker exec -it cont-mysite-01 service apache2 status

docker exec -it cont-mysite-01 service cron status

Link that helped me:

http://www.idein.it/joomla/14-docker-php-apache-with-crontab

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.