Edit a container's /etc/hosts through its host-side file instead of docker exec - #150
Merged
Conversation
…ead of docker exec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
docker execrefuses on a paused container, so the exec-based hosts editssilently skipped exactly the containers that most needed them: a teardown
racing the
docker pausethat follows it left the entry behind, pointing atan overlay IP whose tunnel was just deleted. Nullnet resumes with
unpause,which does not regenerate /etc/hosts, so it survived.
Setup, teardown and the startup purge now share one
edit_container_hostshelper that edits the bind-mounted file from the host side, and enumeration
moved to
docker ps -aq. The path comes fromdocker inspect {{.HostsPath}}rather than a hardcoded /var/lib/docker/... — that assumption breaks under a
custom data-root, a snap install, or rootless docker. The write is in place:
the container sees the file through a bind mount on the inode, so temp-file +
rename would detach its view.
Fixes #147.