I am using docker for Nginx which is running with multiple virtual hosts. Sometimes I have to reload my updated nginx configurations, but I don’t want restart the container each time. Here is how you can reload your nginx without any downtime and without interrupting any connections.
1. Find your container name
Use docker ps to find your nginx container.
2. Reload Nginx
With docker exec -it {container_name} {command} you can directly access your container and execute commands. In my case the name of the container is nginx-server.
1 2 |
$ docker exec -it nginx-server nginx -s reload 2016/08/18 09:52:38 [notice] 19#19: signal process started |
Thank you for the clear guide!
Thank you!
This is an easy way to reload the config from within the container.
Since this was written a while ago, I’m sure there have been many changes that have come about for docker… one such change is that you may be able to reload the config by sending the HUP kill signal to the container, e.g.
docker kill -s HUP
It works only in container, that had run with
--restart always
Very nice blog post. I certainly appreciate this site.
Keep it up!
This helped me a lot, thank you!
Thanks! I needed it for updating certificates periodically
Thanks. It works!
nice … it works for me