Docker Apache impossible restart : httpd already running


In Docker stacks I created (here and here), I realized after few usages that I could encounter problem during stack restart. Apache will not start with following message : httpd (pid: XX) already running.


I usually use docker-compose stop to stop my stacks between projects. It's different from docker-compose down because it doesn't destroy containers, but just stop them. In an ideal world, no problem with that, furthermore it's a bit faster.

In other hand, if stack stops because of any crash, containers can be totally unusable. Due to Apache internal architecture, a new start will find /var/run/apache2/ file and container system will not launch Apache to avoid (as it seems to it) second running instance.


2 parts here : 1. Use docker-compose down rather than docker-compose stop. Dockerily speaking, it's best practice because each container will be recreated from scratch each time you need to work with. As you have persisted what you need to store in volumes, you lost nothing. 2. Customize you Apache image to remove this lock file when container is re-created.

Tags: docker, apache