Docker containers see config file permission change after editor 'atomic save' — bind-mounted file temporarily unreadable until container restart
Environment
Ubuntu 22.04 LTS host running Docker Engine 24.0.2, containers running nginx:stable with a host bind mount /etc/nginx/conf.d/site.conf -> /etc/nginx/conf.d/site.conf inside container. Host edits done via VS Code's default save (atomic write) plugin which writes to a temp file then renames.
Symptoms
After saving the configuration file from the host editor, nginx inside the container reports 'open() "/etc/nginx/conf.d/site.conf" failed (2: No such file or directory)' and serves a default page until the container is restarted or the file is re-chmod/chown from within the container. The host file exists with correct content and permissions immediately after save. Container sees a different inode; some processes show 'file not found' until manual in-container operations are performed.
Observations
On the host, ls -li /etc/nginx/conf.d/site.conf shows inode A before edit, and inode B after save (atomic rename). Inside container, /etc/nginx/conf.d/site.conf may still reference inode A but the file path points to inode B on the host FS; nginx opened old FD and failed because it accessed via opened path? strace inside container shows attempts to open path and receiving ENOENT intermittently. Mount is a bind mount from ext4 host into overlayFS used by Docker; journalctl shows kernel warnings about 'overlayfs: revalidate: lower inode changed' around the time of edit. Restarting nginx inside container sometimes fixes, but not reliably without restarting the container.
Already attempted
Replaced editor save behavior to non-atomic (disabled atomic saves in VS Code) — this reduced occurrences but did not eliminate the issue. Tried using 'docker cp' to copy file into container which works consistently. Upgraded Docker Engine to latest stable, restart docker daemon; issue still reproducible. Verified host permissions and SELinux/AppArmor not enforcing (AppArmor in complain mode).
Question
Why does an atomic rename on the host break a bind-mounted file inside an overlay-backed container, and what reliable, reversible changes to host editor, Docker mount flags, or container configuration avoid breaking processes that expect the file to be continuously present?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Servers42% match
After a kernel upgrade Docker containers get 'permission denied' writing to bind-mounted volumes (overlay2/overlayfs change)
Open0 answers - Virtualization31% match
Docker containers lose DNS resolution after laptop resume on Ubuntu 22.04 due to systemd-resolved stub resolver change
Open0 answers - Cloud Computing25% match
Kubernetes: ConfigMap updates not reflected in pods using projected volume unless pod restarted (changes appear after 2–3 minutes only sometimes)
Open0 answers - Linux23% match
Ubuntu 22.04 host suspend/resume breaks LXD container veth interfaces — containers lose external network
Open0 answers - Linux21% match
Docker containers lose DNS after laptop resumes from sleep
Open1 answer