Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make changes to httpd.conf of apache running inside DOCKER container and restart apache

Tags:

I am new to docker. In our docker environment - Apache has been installed and it is up and running.
Now I need to get into the container, modify the httpd.conf, save it and then I need to restart the apache.

Can you guys please let me know, what needs to be done. I am pretty much confused about - 'exec' and 'attach' commands.

like image 517
Sunag Sunagms Avatar asked Dec 24 '15 08:12

Sunag Sunagms


People also ask

How do I know if Apache is running in docker container?

In your case, try running the script in the Dockerfile located in the /usr/local/bin/ directory as the CMD command and re-run docker-compose up -d to see if the Apache is started or not.


1 Answers

No need to attach or exec (which is really a debug feature anyway)

You can use docker cp to copy a local version of your httpd.conf to the container. (That way, you can modify the file from the comfort of your local environment)

docker cp httpd.conf <yourcontainer_name>:/path/to/httpd.conf 

Once that is done, you can send an USR1 signal to ask for a graceful restart (see docker kill syntax):

docker kill --signal="USR1" <yourcontainer_name> 

Replace <yourcontainer_name> by the container id or name which is running Apache.

That will only work if the main process launched by your container is

CMD ["apachectl", "-DFOREGROUND"] 

See more at "Docker: How to restart a service running in Docker Container"

like image 167
VonC Avatar answered Oct 17 '22 09:10

VonC