Modified Nginx configuration in docker does not work

< H2 > description < / H2 >

I used the data volume to start the container, docker run-- name nginx-container-v / root/nginx/nginx.conf:/etc/nginx/nginx.conf-p 80:80-d nginx

I modified the local configuration file and sent the restart command through docker exec-it nginx-container nginx- s reload . I found that it didn"t work. I still used the original configuration file. I had to docker stop nginx-container and then docker start nginx-container

. < H2 > questions < / H2 > Is

my usage wrong? You still can"t do this. If you use a data volume, you should modify the configuration in the container. However, if I connect to the container to check, it is still the original configuration, indicating that the local modification has not taken effect. Is there any link missing?

I see that when officials map data volumes, they add ro at the end, which means read-only. I should have permission to modify anything, right?

-v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro

in addition, I map a local index.html to the container, visit the home page, and modify the local index.html, which is effective, but not the mapping configuration file.

May.26,2022

docker exec-it nginx-container service nginx reload

Menu