Skip to content

fix: give the pod a resolvable hostname (own-hostname resolution)#82

Merged
lesnik512 merged 1 commit into
mainfrom
fix/pod-hostname-own-resolution
Jul 22, 2026
Merged

fix: give the pod a resolvable hostname (own-hostname resolution)#82
lesnik512 merged 1 commit into
mainfrom
fix/pod-hostname-own-resolution

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Problem

0.4.0 moved pod-internal name resolution into a script-owned /etc/hosts under --no-hosts (to kill the pre-6.0.0 stop-wipe bug). But --no-hosts also stops Podman from adding each container's own hostname line. The container's hostname is then the random container ID, absent from the owned file, so:

hostname: Temporary failure in name resolution

Images whose startup resolves their own hostname — e.g. a KeyDB-sentinel image whose supervisor does — crash-loop and never go healthy, so wait_healthy times out. This is a regression from 0.1.8, which used no --no-hosts and let Podman add the own-hostname line (it worked there even with a random container-ID hostname).

Fix

  • podman pod create gains --uts private --hostname <pod-name>. --uts private is required — in the host UTS namespace Podman refuses --hostname (cannot set hostname ... host UTS namespace). A pod shares one UTS namespace, so per-container hostnames are impossible on 5.x/6.x (verified); the pod name is the single shared hostname.
  • Add 127.0.0.1 <pod-name> to the owned /etc/hosts so that hostname resolves.

Per-service hostname: keys are unchanged: resolvable by peers via the hosts file, not set as a container's own name (0.1.8 didn't honor them as real hostnames either, and the value is irrelevant to resolution).

Verification

  • Reproduced the failure and the fix end-to-end on real Podman 5.8.1 (quay.io/podman/stable:v5.8.1) and local 6.0.1: a service whose healthcheck is hostname -f goes healthy, and a peer resolves its own hostname (OWN-HOSTNAME-OK).
  • Confirmed the JSON-array --health-cmd compose2pod emits for ["CMD", ...] is accepted by Podman 5.8.1 (the healthcheck rendering was not the bug).
  • TDD: failing test_pod_gets_private_uts_and_hostname first, then fix.
  • just test-ci — 1403 passed, 100% coverage. just lint-ci — clean.

Rationale: planning/changes/2026-07-22.02-pod-hostname-own-resolution.md. Architecture promoted in architecture/supported-subset.md (owned-/etc/hosts bullet).

…s own hostname

0.4.0 moved name resolution into a script-owned /etc/hosts under
--no-hosts to kill the pre-6.0.0 stop-wipe bug. But --no-hosts also
stops Podman from adding each container's own hostname line, so the
hostname is the random container ID, absent from the owned file:
hostname -f then fails with 'Temporary failure in name resolution' and
an image whose startup resolves its own hostname (e.g. a KeyDB-sentinel
image) crash-loops and never goes healthy -- a regression from 0.1.8,
which used no --no-hosts and let Podman add the line.

Give the pod a private UTS namespace and the pod name as hostname
(podman pod create --uts private --hostname <pod>; --uts private is
required, Podman refuses --hostname in the host UTS namespace), and add
127.0.0.1 <pod> to the owned /etc/hosts. A pod shares one UTS namespace,
so the hostname is pod-wide; per-service hostname: keys are unchanged.
Verified end-to-end on Podman 5.8.1 and 6.0.1.
@lesnik512
lesnik512 merged commit f973cf4 into main Jul 22, 2026
8 checks passed
@lesnik512
lesnik512 deleted the fix/pod-hostname-own-resolution branch July 22, 2026 12:27
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