Everyone know that the host where Docker is running shouldn't need to know anything about what's inside such Docker container. Because of that I am trying to add support for run cronjobs
inside the container. After read some posts about how to achieve this like the ones listed below:
- https://www.ekito.fr/people/run-a-cron-job-with-docker/
- How to run a cron job inside a docker container?
- http://www.anotherchris.net/posts/running-cron-jobs-inside-a-docker-container
I am trying to implement my "custom" solution with the following image.
This is what I did:
- Added a file api_command-cron to the directory
/config/etc/cron.d
- Added a file api_command.sh to the directory
/usr/local/bin
In addition I have added the following changes to the entrypoint.sh file:
##################################################################
# Setup CronJobs
##################################################################
ln -sfn /var/www/html/oneview_symfony/bin/console /bin/sfconsole
# Disable this cronjob if the ENV variable is false
if [ "${ENABLE_API_CRON}" == "false" ]
then
# Disable the cronjob
sed -i '/0/s/^/#/g' /etc/cron.d/api_command-cron
fi
echo "API Cron Status: ${ENABLE_API_CRON}"
Because I am using a Docker Compose (docker-compose.yml) stack this is how I build the container:
$ docker-compose up --force-recreate --build --remove-orphans
The build process went fine and the container startup without any issues.
Successfully built 64ee76d6fbe4
Successfully tagged dockerlamp_webserver:latest
Creating dockerlamp_webserver_1 ...
Creating dockerlamp_webserver_1 ... done
Attaching to dockerlamp_webserver_1
webserver_1 | UID: 1000
webserver_1 | GID: 1000
webserver_1 | API Cron Status: true
webserver_1 | Enabling module rewrite.
webserver_1 | Enabling module expires.
webserver_1 | To activate the new configuration, you need to run:
webserver_1 | service apache2 restart
webserver_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.2. Set the 'ServerName' directive globally to suppress this message
As soon as I try to access the application through http://localhost
I got a blank page and no logs at all. The issue is not the application since the same sources did work on the image from the master
branch which doesn't have this new changes.
Why the application stop working in this scenario?