Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart apache2 without terminating docker container?

Tags:

I am using as a base the php docker container with the tag:

php:5.6-apache 

When I try to restart the apache2 inside the container, the container stops:

root@phalconapp:/var/www/html# service apache2 restart Restarting web server: apache2Terminated root@phaclonapp:/var/www/html# me@myLocalComputer: 

How to restart apache2 without stopping the container?

I want to play around with the container and customize it, before I put my changes into the dockerfile. I want to install some extension and for them to work I need to restart apache for the changes to take effect.

This is the log file via:

Attaching to dltasklight_phlaconapp_1 phlaconapp_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message phlaconapp_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message phlaconapp_1 | [Mon May 30 10:19:24.556154 2016] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/5.6.22 configured -- resuming normal operations phlaconapp_1 | [Mon May 30 10:19:24.556181 2016] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND' phlaconapp_1 | [Mon May 30 10:21:11.754993 2016] [mpm_prefork:notice] [pid 1] AH00169: caught SIGTERM, shutting down dltasklight_phlaconapp_1 exited with code 0 
like image 773
k0pernikus Avatar asked May 30 '16 10:05

k0pernikus


People also ask

What is restart unless stopped docker?

This means that with the unless-stopped restart policy, if the container was running before the reboot, the container would be restarted once the system restarted. When an application within a Docker container exits, that container will be also halted.


1 Answers

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 
like image 61
Cau Avatar answered Sep 25 '22 01:09

Cau