You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use Apple container's built-in DNS for inter-container resolution when domain is registered #81
Today, services in the same compose project can't resolve each other by name — getent hosts db from inside app returns nothing, so configs that use DB_HOST: db (the docker-compose default) just don't work. Users have to pin IPs into env vars or manually script extra_hosts.
Apple container already ships a DNS server that the daemon's bridge gateway answers on, for any domain registered via container system dns create <domain>. So we can register a domain per project, run containers with dotted names like db.<domain>, and get real DNS for free:
--dns-domain <domain> is passed to container run, which writes nameserver <gateway> + domain <domain> into the container's /etc/resolv.conf
Both db (short, via the implicit search list) and db.<domain> (FQDN) resolve through the daemon's DNS server
In ComposeUp.run() it's just: derive a DNS label from projectName (lowercased, [a-z0-9-], ≤63 chars), shell out to container system dns list to check whether it's registered, and use the path above when it is. When it isn't, current behavior is unchanged plus a one-time printed note pointing at sudo container system dns create <domain>.
Tested with apple/container 0.12.3 on macOS 26. Two alpine containers db.testdomain and app.testdomain started with --dns-domain testdomain. From inside app:
No /etc/hosts mutation, no per-container exec, survives container restarts (daemon updates the registration when IPs change).
The catch:sudo container system dns create <domain> is one-time per project and requires admin. For users who refuse sudo, behavior is unchanged.
I have a working implementation if you want it — ~70 net lines in ComposeUp.swift, a small sanitizer helper, ~15 unit tests, and one dynamic test that auto-skips if no domain is pre-registered. Happy to send a PR.
Sent #97 — sanitize + detect + dotted naming + hosts fallback + multi-shape ComposeDown cleanup, plus tests. Skips gracefully when no domain is registered.
One thing this PR intentionally leaves out: removing the sudo requirement for container system dns create.
Right now users need to run sudo container system dns create <domain> once per project before the DNS path activates. That's fine for power users but a friction point for everyone else.
I've been prototyping a small setuid-root helper (~170 lines of C) that does exactly the file-side work of dns create/dns delete — writes /etc/resolver/containerization.<domain> and HUPs mDNSResponder — with strict domain validation and no shell-out. One-time sudo make install-helper, then compose up registers domains on demand with no password prompt.
The helper would live in a helper/ directory in this repo. Curious what folks think — is a C setuid binary acceptable here, or would you rather keep it pure Swift and just require the manual sudo step?
Activity
Mcrich23 commentedon May 29, 2026
I support this change!
Cyb3rDudu commentedon May 29, 2026
Sent #97 — sanitize + detect + dotted naming + hosts fallback + multi-shape ComposeDown cleanup, plus tests. Skips gracefully when no domain is registered.
Cyb3rDudu commentedon May 29, 2026
One thing this PR intentionally leaves out: removing the sudo requirement for
container system dns create.Right now users need to run
sudo container system dns create <domain>once per project before the DNS path activates. That's fine for power users but a friction point for everyone else.I've been prototyping a small setuid-root helper (~170 lines of C) that does exactly the file-side work of
dns create/dns delete— writes/etc/resolver/containerization.<domain>and HUPs mDNSResponder — with strict domain validation and no shell-out. One-timesudo make install-helper, thencompose upregisters domains on demand with no password prompt.The helper would live in a
helper/directory in this repo. Curious what folks think — is a C setuid binary acceptable here, or would you rather keep it pure Swift and just require the manual sudo step?