feat: own /etc/hosts via --no-hosts (support Podman 5.x)#79
Merged
Conversation
Review found the task-1 brief's snippet dropped three merge-behavior regressions covered by the old TestAddHostFlags: alias/extra_hosts coexisting on different hosts, the same-host/same-address dedup that flips a host's token from literal to Expand, and non-closure services being ignored.
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.
Summary
Makes the generated pod script own
/etc/hostsinstead of relying on pod-level--add-host, so pod-internal name resolution is correct on every Podman version — including Podman 5.x, which has no fix for the multi-container/etc/hostsstop-wipe bug (fixed only in 6.0.0, PR #28494, not backported to any 5.x). This removes compose2pod's Podman >= 6.0.0 requirement entirely.The script now passes
--no-hoststopodman pod createand everypodman run, writes a full hosts file at run time (hostsfile=$(mktemp)), and bind-mounts it read-only into each container (-v "$hostsfile":/etc/hosts:ro,z). With--no-hosts, Podman never manages/etc/hosts, so the stop-path that wiped it cannot fire. The:zrelabel is mandatory on SELinux Fedora and a no-op elsewhere (validated end-to-end in a Fedora CoreOS VM).Rationale, research, and rejected alternatives:
planning/changes/2026-07-20.01-own-etc-hosts-via-no-hosts.md.Behavior changes
podman pod create/ every run gains--no-hosts; no--add-hostanywhere.127.0.0.1 localhost,::1 localhost, each alias/hostname →127.0.0.1, eachextra_hosts→ its address; removed on teardown.host.containers.internal/host.docker.internalare no longer provided (cannot resolve the gateway IP under--no-hosts); add an explicitextra_hostsentry if needed.extra_hostsare unchanged.Testing
just test-ci: 1400 passed, 100% line coverage.just lint-ci: clean.integrationCI job (ubuntu-latest, native bind mounts) exercises name resolution surviving a completion container's stop.🤖 Generated with Claude Code