Why sed -i File Edits on the Host Don't Reach Docker Containers
Engineers debugging a Prometheus configuration issue discovered that running sed -i on a host file did not update the content visible inside a Docker container, even though the host file appeared correctly modified. The root cause lies in how sed -i actually works: rather than editing a file in place, it writes changes to a temporary file and then renames it over the original path. Because Docker bind-mounts a single file by inode rather than by directory entry, the container retains an open file descriptor to the original inode, which becomes a 'ghost' with zero hard links after the rename operation. Running stat and md5sum both inside and outside the container confirmed the two paths were pointing to entirely different inodes with different content. The fix requires restarting the container after such edits, or using write-in-place tools that modify the original inode directly instead of replacing it.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in