Skip to content

Add service DNS, host.docker.internal, optional deps, --remove-orphans, up -d - #21

Merged
flaticols merged 3 commits into
mainfrom
feat/compose-issues-16-20
Oct 15, 2026
Merged

flaticols merged 3 commits into
mainfrom
feat/compose-issues-16-20

Conversation

@flaticols

@flaticols flaticols commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #16, #17, #18, #19, #20.

why

Apple container 1.3.1 resolves no container names at all: getent hosts <peer> is NXDOMAIN on the default and on a custom network, --network name,alias= is rejected, and the only DNS is the opt-in [dns] domain in config.toml, which registers <container>.<domain>, not service names. So redis never resolved from another service and there was no host.docker.internal. Verified on container 1.3.1 / macOS 27.

what changed

ProjectHosts writes one hosts file per service container under ~/.local/state/container-compose/<project>/hosts/, mounted over /etc/hosts: peers on a shared network by service name, container name and aliases, plus host.docker.internal (the network gateway) and extra_hosts incl. host-gateway. up and start refresh the files as containers come up; down removes them. ContainerRecord decodes the few fields needed from container list / inspect.

up -d is accepted. up / down --remove-orphans drop containers whose service label is no longer in the file; up warns otherwise. depends_on.required: false comes from ComposeKit 0.0.5 (flaticols/ComposeKit#17).

Apple container 1.3.1 resolves no container names: peers are NXDOMAIN on every
network, `--network name,alias=` is rejected, and the opt-in `[dns] domain` registers
`<container>.<domain>`, not service names. Nothing resolved `redis` from another
service and there was no `host.docker.internal`.

ProjectHosts writes one hosts file per service container under
~/.local/state/container-compose/<project>/hosts/ and the translator mounts it over
/etc/hosts. It lists project containers on a shared network under service name,
container name and aliases, plus host.docker.internal/gateway.docker.internal (the
network gateway) and extra_hosts incl. host-gateway. up/start inspect each container
after start and rewrite the files of peers sharing a network; down removes them.
Rewrites are in place and padded to 4 KiB: the guest bind mount pins the inode and
virtiofs caches the size for ~1 s, so a growing rewrite was read truncated.

`up -d` is accepted. `up`/`down --remove-orphans` remove containers with the project
label whose service label is gone from the file; `up` warns otherwise.
depends_on.required comes from ComposeKit 0.0.5; `config` hides optional deps outside
the plan.

Localhost-bound Mac listeners stay unreachable through the gateway. With
`sudo container system dns create host.docker.internal --localhost <ip>` registered,
the hosts entry is skipped so container's DNS answers.

Closes #16, #17, #18, #19, #20.

Claude-Session: https://claude.ai/code/session_011sCioLoXQJi1yNF7q4gYmJ
@flaticols
flaticols marked this pull request as ready for review October 15, 2026 12:07
addressBook(for:) seeded only running containers, so `up` never warned about or removed a stopped orphan. down was unaffected. Stopped records carry no addresses, so hosts rendering is unchanged.

Claude-Session: https://claude.ai/code/session_011sCioLoXQJi1yNF7q4gYmJ
The tag moved to the squash-merge commit 68bb824 after flaticols/ComposeKit#17 landed; same sources plus the nightly schema sync.
@flaticols
flaticols merged commit 7b587a0 into main Oct 15, 2026
1 check passed
@flaticols
flaticols deleted the feat/compose-issues-16-20 branch October 15, 2026 12:14
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.

Support of up -d

1 participant