0

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:

I am trying to implement my "custom" solution with the following image.

This is what I did:

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?

ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • 1
    post your Dockerfile also – Tarun Lalwani Sep 21 '17 at 16:23
  • 1
    also might be worth also when running the containers to run a docker ps, copy the webserver id and then run docker logs and paste it here – Sergiu Sep 21 '17 at 16:28
  • @TarunLalwani done – ReynierPM Sep 21 '17 at 17:01
  • @Sergiu done ... – ReynierPM Sep 21 '17 at 17:01
  • 1
    First of all you should try and customize official php image with apache instead of starting from ubuntu. Also you should not use service command inside docker. Better is to the run the apache process in foreground. See the official image and you will get a better idea – Tarun Lalwani Sep 21 '17 at 17:10
  • @TarunLalwani this image was built for my office and they *DO NOT WANT* to use official images because they want to keep this closer as much as what we had before meaning a monolith server running Ubuntu and that specific version. I understand you and I would love to make a jump but my hands are tied. Anyway thanks – ReynierPM Sep 21 '17 at 17:12
  • No worries, you should run `ps aux` inside the container and `netstat -plant` and `curl -v localhost` inside the container and add its output to the question – Tarun Lalwani Sep 21 '17 at 17:14
  • @TarunLalwani added – ReynierPM Sep 21 '17 at 17:33
  • So the container from inside looks healthy. Can you do a `curl -v 127.0.0.1` on the docker host machine? – Tarun Lalwani Sep 21 '17 at 17:50
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/155031/discussion-between-tarun-lalwani-and-reynierpm). – Tarun Lalwani Sep 21 '17 at 17:50

0 Answers0