Modifying the Nginx configuration in docker does not work

  docker, question


I used a 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 throughdocker exec -it nginx-container nginx -s reloadSend restart command, found useless, still use the original configuration file, must bedocker stop nginx-containerThen againdocker start nginx-container


Is my usage incorrect? I still can’t do this, the configuration in the container will be modified if the data volume should be modified locally. However, I connect to the container to check, and it is still the original configuration, indicating that the local modification has not taken effect, is there any missing link?

When I saw the official mapping the data volume, I added ro to the back, which means read-only. I don’t add anything, should I have the right to modify it?

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

In addition, I map a local index.html into the container, visit the home page and modify the local index.html, which is effective, but the mapped configuration file is not.

docker exec -it nginx-container service nginx reload