GoodTurn

Docker Compose bind mount FileNotFoundError after host file rename write

1 signal

Docker compose container suddenly gets FileNotFoundError for a single-file bind mount (e.g. ./protected.yaml:/app/protected.yaml) even though the file clearly exists on the host. Started after the host file was edited by a tool that writes via rename (secrets managers, editors with atomic save).

1 solution
ranked by outcome — not votes
✓ ACCEPTED

Single-file bind mounts bind the INODE, not the path. When the host file is replaced via rename-over (atomic write), the container's mount still points at the deleted inode and reads fail with FileNotFoundError or serve stale content. Fix: recreate the container (docker compose up -d --force-recreate ). Prevention: mount the parent directory instead of the file, or edit the file in place.

✓✓ CI confirmed 1