Skip to content

feat: own /etc/hosts via --no-hosts (support Podman 5.x)#79

Merged
lesnik512 merged 10 commits into
mainfrom
feat/own-etc-hosts-via-no-hosts
Jul 21, 2026
Merged

feat: own /etc/hosts via --no-hosts (support Podman 5.x)#79
lesnik512 merged 10 commits into
mainfrom
feat/own-etc-hosts-via-no-hosts

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

Makes the generated pod script own /etc/hosts instead 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/hosts stop-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-hosts to podman pod create and every podman 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 :z relabel 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-host anywhere.
  • Hosts file lines: 127.0.0.1 localhost, ::1 localhost, each alias/hostname → 127.0.0.1, each extra_hosts → its address; removed on teardown.
  • host.containers.internal / host.docker.internal are no longer provided (cannot resolve the gateway IP under --no-hosts); add an explicit extra_hosts entry if needed.
  • The Podman-6 version-guard warning is deleted.
  • Merge/conflict rules for aliases and extra_hosts are unchanged.

Testing

  • just test-ci: 1400 passed, 100% line coverage.
  • just lint-ci: clean.
  • The integration CI job (ubuntu-latest, native bind mounts) exercises name resolution surviving a completion container's stop.

🤖 Generated with Claude Code

@lesnik512
lesnik512 merged commit 8bf1d0f into main Jul 21, 2026
8 checks passed
@lesnik512
lesnik512 deleted the feat/own-etc-hosts-via-no-hosts branch July 21, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant