Configuration files need to update without rebuilding the image.
BeginnerScenarioVolumes, storage and data
Answer
Situation read → Config is separate from code.
What I'd do → Mount it read-only: -v $PWD/nginx.conf:/etc/nginx/nginx.conf:ro, or in Compose use configs:. Reload without restart: docker exec web nginx -s reload.
Why → Same image, different behaviour, and a simple rollback of config.
Interview tip → Single-file bind mounts break on editors that replace the inode (vim); mount the directory.
More on Volumes, storage and data
A Postgres container was removed and the data is gone. How should it have been run?BeginnerBind mount or named volume for local development of a Node app?BeginnerHow do you back up a named volume?IntermediateTwo containers must share files. What are your options?BeginnerA container needs a writable temp area but the root filesystem is read-only.IntermediateMoving a database volume from one Docker host to another.Intermediate