Repository navigation
Description
Feature or enhancement request details
Please add first-class container-to-container DNS discovery for containers attached to the same container network, including bare container names and network aliases.
This came up while testing Compose-compatible workflows with container-compose. Compose users expect service names such as web, db, and network aliases to resolve from peer containers on the same network without a global host DNS setup step.
Related tracking:
- Existing DNS bug/discussion: [Bug]: internal DNS does not work (clean install) #856
- Compose compatibility tracker: Track Compose compatibility gaps found with apple/container 1.0.0 Mcrich23/Container-Compose#118
- Container-Compose service discovery issue: Services on the same Compose network cannot resolve service names Mcrich23/Container-Compose#114
- Container-Compose network aliases issue: Parse Compose service network object form for aliases Mcrich23/Container-Compose#116
Current behavior on container 1.0.0:
container system start
container network create appnet
container run -d --name network-web --network appnet nginx:alpine
container run --rm --network appnet busybox:latest nslookup network-webThe peer container receives the network gateway as its resolver:
container exec network-web cat /etc/resolv.conf
# nameserver 192.168.65.1The container is reachable by IP from the same network, but name lookup returns NXDOMAIN:
Server: 192.168.65.1
Address: 192.168.65.1:53
** server can't find network-web: NXDOMAIN
The currently documented workaround appears to be configuring a DNS domain with container system dns create <domain> plus setting dns.domain. That can make FQDN/search-domain flows work, but it is not the same as network-scoped, Compose-style service discovery. It also requires global host DNS configuration for what is usually expected to be a per-network container runtime feature.
A useful end state would be one of these:
- Containers on the same network can resolve each other by container name, for example
web-> that container's network IP. - The network layer supports additional network-scoped aliases so higher-level tools can map Compose service names and aliases onto Apple Container networks.
- If bare names are intentionally out of scope, expose a supported CLI/API path that tools can use to create network-scoped DNS domains/aliases without requiring users to manually toggle global DNS settings.
Environment used for the repro:
- OS: macOS 26.5.1 (25F80)
- Xcode: 26.5 (17F42)
- Container: container CLI version 1.0.0 (build: release, commit: ee848e3)
- Architecture: arm64I agree to follow this project's Code of Conduct.
Activity
thromel commentedon Jun 25, 2026
Update: I opened a draft implementation PR for the container-facing DNS part:
What it covers:
The PR is intentionally draft/RFC because it binds wildcard UDP 53 and currently discovers upstreams from
/etc/resolv.conf; both are design choices that should get maintainer review.It is stacked on #1810 because the DNS path needs the hostname normalization/trailing-dot behavior from that PR.
Remaining work for Compose-style parity: explicit network aliases/service aliases still need API/CLI support after the bare-hostname DNS path is settled.
thromel commentedon Jun 25, 2026
Follow-up draft PR for explicit aliases is open:
This stacks on #1813 and adds a narrow alias registration path:
AttachmentOptions/Attachmentcarryaliases--network backend,alias=db,alias=databaseparses repeated aliasesI could not complete live alias validation because the local debug apiserver launch did not become healthy during the smoke-test attempt. Unit/build coverage is included in the PR body, and the installed
/usr/localservice was restored afterward.thromel commentedon Jun 25, 2026
Status update:
/usr/localrelease service was restored after the smoke attempt.thromel commentedon Jun 25, 2026
Status update: #1815 is now ready for review.
I was able to complete live alias validation by staging the debug build into a temporary install root and starting the service with explicit
--install-root/--log-rootsettings.Validated behavior:
container run --network codex-alias-live,alias=db,alias=database ...registers both aliasesdb,database, and the primary container name through the network gateway DNSalias=dbattachment fails with the expected duplicate-hostname error/usr/localrelease service was restored and verified healthyJakeshadow commentedon Jun 30, 2026
FQDN-based service discovery is one of the biggest differences from Docker Compose networking. In our testing:
<container-name>.containers.localWe documented the FQDN patterns, working examples, and the cross-network workaround (manual host mapping) at maccontainer.dev/installation/ — the troubleshooting section covers this exact DNS issue.
It's not Docker's DNS-based service discovery, but the FQDN pattern is predictable once you know the naming convention.
thromel commentedon Jul 1, 2026
Thanks, that matches the same-network constraint I’ve been seeing. I think the useful invariant is “container ID/name + configured DNS domain” rather than a Docker-style per-network service-name registry; depending on local DNS config that can show up as
<container>.containers.local,dev.internal, or another configured domain.For Compose parity, the remaining gap is still bare service names and aliases (
db,database) on the service network, because Compose files generally do not want to depend on the full generated container FQDN. That is what #1815 is trying to cover narrowly: register aliases on the same network attachment and keep duplicate-name checks scoped there.I agree cross-network / multi-compose-file discovery is a separate problem and should stay out of this first pass.
devops-thiago commentedon Aug 9, 2026
We needed exactly this for compose-shaped workflows on container 1.2.0, so here is what we measured and what we ended up building, in case either is useful.
First, port data that complements the #1813 design note. The gateway binds there failed with EADDRNOTAVAIL from the helper. From plain user space, with a container running and the bridge up so the gateway address exists, the failure is different and harder:
Every port below 1024 is EPERM for an unprivileged process on current macOS, both TCP and UDP, on every address we tried. So a container-facing listener on 53 cannot exist host-side for a non-root engine at all. resolv.conf cannot carry a port, which rules out the unprivileged ports that do bind. The only place a :53 listener can live is inside the guest, which is vminitd territory rather than the engine's.
What we built instead needs no listener. When a container joins a network, the runtime asks the network helper for everything already attached (one new XPC route that returns the current attachments) and writes each peer into the joining guest's /etc/hosts, bare and qualified:
The guest's resolv.conf also gets
search container.internalwhen no domain was configured. Since getaddrinfo consults hosts before DNS, service names resolve inside the containers with no resolver in the path and no root anywhere. Verified by starting nginx asdnsweb, then a second container, and fetchinghttp://dnsweb/andhttp://dnsweb.container.internal/from it.The limitation is honest: hosts files are written at boot, so a container does not learn about peers that start after it. A stack brought up in dependency order, which is what compose does, sees every name it needs. Aliases from #1815 would slot into the same hosts entries.
The patch is small (allocator enumeration, the XPC route, client call, hosts composition in the runtime, about 150 lines). Glad to open a PR if the maintainers want it as an interim step while the DNS listener work in #1813 evolves.
thromel commentedon Aug 10, 2026
l-hedgehog commentedon Aug 22, 2026
Hi @thromel, I asked deepseek-v4-flash-0731 to build a customized vminitd image as described in this doc that attachs some eBPF which will redirect any traffic to a loopback address (hardcoded to 127.0.8.6 for now) at port 53 to a real dns server (defaults to 1.1.1.1:53, but can be set to any other {ip}:{port}). I'm new to both eBPF (where the code looks simple enough and reasonable to me) and vminitd (where the code
I didn't even try to readwas migrated to aya and much more readable), but it does work as expected. Hopefully this is somewhat useful or at least interesting for the container-facing DNS work. You could try it withcontainer run -it --rm --init-image ghcr.io/l-hedgehog/aa-tils/vminitd-ebpf-dns:0.45.0 --kernel-arg dnslink.gateway={ip} --kernel-arg dnslink.port={port} --dns 127.0.8.6 {image}.Stop promising DNS the runtime does not have
andrew-waters commentedon Sep 16, 2026
A downstream data point, since this one is the single biggest compose-compatibility gap I have hit.
I maintain compose, a
container composeplugin, and Orchard. Because hostnames have to be unique across every container on the machine, a service declared asdbhas to be brought up asmyapp-db. That is fine for the container list, and fatal for compose compatibility: essentially every compose file in the wild haspostgres://db:5432orredis://cachehard-coded into an environment variable, because on Docker the service name resolves on the project network.So the practical cost of this issue is not "nice DNS ergonomics", it is that compose files cannot be moved across unedited, which is the entire reason people want compose here. Per-network name scoping, as described above, would fix it outright. Happy to test against real projects if that is useful to whoever picks it up.
Worker nodes, container snapshots, and compose services found by name
Chadzilla commentedon Oct 29, 2026
Adding another real-world data point for this issue.
Environment:
Problem:
I’m running Zabbix as a three-container monitoring deployment. Following a restart, the containers received different IP addresses, but Zabbix retained the previously configured addresses.
For example:
The frontend became inaccessible, repeatedly logging:
PostgreSQL server is not available. Waiting 5 seconds...
I also tested container-name resolution:
container exec Zabbix-Web getent hosts Zabbix-DB
This returned no result.
Workaround:
I restored functionality by recreating the Zabbix application containers with updated DB_SERVER_HOST and ZBX_SERVER_HOST environment variables.
The PostgreSQL database itself was unaffected.
Impact:
Because container IP addresses are dynamic and bare container-name resolution does not work in my current configuration, multi-container applications cannot reliably recover from restarts without additional orchestration.
I understand that FQDN-based discovery may be possible with additional DNS configuration, but this is not equivalent to automatic network-scoped service discovery.
It would be helpful to have reliable container-name or network-alias resolution, particularly for applications with persistent database dependencies.
Thanks for the work on this project!
yada commentedon Nov 14, 2026
Another data point for this, from a clustering use case (reShapr MCP gateway, which uses Infinispan/JGroups). Repro and notes: https://github.com/yada/reshapr-container-poc (
docs/FINDINGS.md, F2 and F3). Tested with container 1.7.1 on macOS 27.2.1. Name resolution needs the sudo step. Containers register as
<name>.test, but a container's resolver forwards to macOS, which only knowstestaftersudo container system dns create test. Without it, a lookup from another container returnsNXDOMAIN(UnknownHostExceptionin the JVM). Re-checked just now: withcontainer run -d --name dnsa --network default,alias=shared alpine sleep 600, a third container'snslookup shared.testandnslookup dnsa.testboth returnNXDOMAINuntil the sudo step is done. After it,<name>.testresolves. So container-to-container discovery currently depends on a host-wide DNS setup, which is the gap this issue describes.2. One name can't map to several containers. DNS_PING-style discovery (JGroups, and anything similar) needs several A records for one name. With the
alias=network option, a second container can't reuse an alias:Reusing a
--namefails the same way (container with id dnsa already exists). So plain containers can't form this kind of cluster, and the only way I found wascontainer cluster(Kubernetes), where a headless Service provides the records. Network-scoped aliases (#1839) cover Compose-style names but would not, on their own, give one name resolving to several containers.If this is in scope, would you rather see multi-A resolution for a shared alias, or leave that to Kubernetes via
container cluster?docs: record apple/container#1809 comment (F2, F3)
docs: update upstream issues status in next steps
SVilgelm commentedon Nov 18, 2026
A workaround that works on 1.7.1: give the target an alias under a per-project subdomain, and add that subdomain to the client's search list.
Bare
dbresolves through the search domain, on custom networks and the default one; a client on another network can't reach it.