Reload Nginx Service Inside Docker Container

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 name.

2. Reload Nginx Service Inside Docker Container

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 webserver4.

$ docker exec -it webserver4 nginx -s reload
2023/01/14 02:21:16 [notice] 472
#472: signal process started

Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *