How to restart apache2 without terminating docker container? How to restart apache2 without terminating docker container? docker docker

How to restart apache2 without terminating docker container?


If you use apache as the primary service to keep your running container, you can NOT reboot it. Simply because you built the image and sets the CMD with it.

The main purpose of a CMD is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well.

Try to reload without restart a service:

/etc/init.d/apache2 reload


My solution to this was to exit my bash shell into the container, and just restart the container outside of Docker. Because Apache is set as the primary service, this also restarts Apache, and doesn't crash the container.

docker restart <container>


sudo docker kill --signal="USR1" your_appache_container

Other signals that you can use to achieve the following :

Stop Now Signal: TERM

Graceful Restart Signal: USR1

Restart Now Signal: HUP

Graceful Stop Signal: WINCH

From: this website