Skip to content

Edit a container's /etc/hosts through its host-side file instead of docker exec - #150

Merged
GyulyVGC merged 1 commit into
mainfrom
paused-etc
Aug 7, 2026
Merged

Edit a container's /etc/hosts through its host-side file instead of docker exec#150
GyulyVGC merged 1 commit into
mainfrom
paused-etc

Conversation

@GyulyVGC

@GyulyVGC GyulyVGC commented Aug 7, 2026

Copy link
Copy Markdown
Member

docker exec refuses on a paused container, so the exec-based hosts edits
silently skipped exactly the containers that most needed them: a teardown
racing the docker pause that follows it left the entry behind, pointing at
an 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_hosts
helper that edits the bind-mounted file from the host side, and enumeration
moved to docker ps -aq. The path comes from docker 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.

@GyulyVGC GyulyVGC self-assigned this Aug 7, 2026
@GyulyVGC GyulyVGC added the enhancement New feature or request label Aug 7, 2026
@GyulyVGC
GyulyVGC merged commit 152af9a into main Aug 7, 2026
8 checks passed
@GyulyVGC
GyulyVGC deleted the paused-etc branch August 7, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/etc/hosts entries are stranded in paused containers, leaving names mapped to dead overlay IPs

1 participant