SoFunction
Updated on 2025-03-10

Docker reload nginx configuration

docker reload nginx configuration

//Modify nginx configuration. If it cannot be restarted, you can reload the new configuration without restarting the Docker container.  Nginx can be configured with hot-reload without restarting.//Query the container id where nginx is located: docker ps -adocker ps -a
//Test nginx configurationdocker exec containerid nginx -t 
//Reload nginx configurationdocker exec containerid  nginx -s reload 

Docker update nginx configuration reload nginx configuration file

Production environment nginx is deployed in docker container

Updated configuration file Reload configuration of configuration file once

operate

Check docker All containers in turn upnginx Can be a name It can be containerid
docker ps -a

Put the following  nginx_container Replace with 上面查出来的container名称 orid

docker exec nginx_container nginx -s reload

pass docker exec 在container内部执行命令 It's OK heredocker Imagine it as a smalllinux

nginx_container To execute internal commands container名 这步指定要执行的container

nginx 指定container内的 process Here it points tonginx

-s reload  Reload configuration file command  This isnginx Instructions provided

Copy directly

docker exec nginx_container nginx -s reload

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.