How can you mount a single file and what pitfall exists?
AdvancedConceptVolumes & Bind Mounts
Answer
-v ./nginx.conf:/etc/nginx/nginx.conf:ro works, but file bind mounts bind to the inode. Editors that replace the file (write to temp then rename) create a new inode and the container keeps seeing the old one. Mount the parent directory instead, or restart the container after edits.
More on Volumes & Bind Mounts
What are the three ways to persist or share data with a container?BeginnerVolume vs bind mount: when do you pick which?BeginnerWhat is the difference between `-v` and `--mount`?BeginnerWhat is an anonymous volume and how do you find leftovers?IntermediateHow does a new named volume get populated?IntermediateHow do you back up and restore a named volume?Intermediate