Skip to content

fix: apply [container.dns] config defaults when Berthly starts the builder - #239

Merged
henrywang merged 1 commit into
mainfrom
fix/builder-dns-defaults
Nov 12, 2026
Merged

henrywang merged 1 commit into
mainfrom
fix/builder-dns-defaults

Conversation

@henrywang

Copy link
Copy Markdown
Owner

Closes #233.

Problem

LiveContainerService.startBuilderContainer is Berthly's copy of upstream's Builder.start, kept separate on purpose (#210). Two things diverged from the CLI:

Changes

Behavior change

  • Builds now resolve through the gateway (192.168.64.1) by default instead of 1.1.1.1, matching container build. Builds behind a VPN or split DNS may resolve differently.
  • The first Berthly build after updating recreates an existing builder once, because it was made with 1.1.1.1. That drops the build cache.

Testing

Local, container 1.7.1 daemon:

  • swiftlint lint --strict: clean
  • BerthlyTests: 619 passed (8 new)
  • E2E via scripts/e2e.sh:
    • ResourceJourneyTests/testBuildImageFromDockerfileThenRun (×5)
    • testBuildWithSSHForwardingMountsAgentSocket
    • MachineJourneyTests/testBuildMachineImageThenBootMachine
  • I watched the buildkit container's startedDate and stored dns across runs:
    1. A builder from before this PR (['1.1.1.1']) was recreated once on the first build, now with []. The second build reused it.
    2. A CLI container build, then a Berthly build: no recreate either way. The CLI build's RUN cat /etc/resolv.conf printed nameserver 192.168.64.1.
    3. With [container.dns] (nameservers = ["9.9.9.9"], searchDomains = [...]) set and the daemon restarted, the builder was recreated with those values, and its /etc/resolv.conf matched. After restoring the config, the builder went back to [].
  • The daemon stores nameservers: [] and only fills in the gateway inside the guest, so the comparison doesn't recreate the builder on every build. I confirmed this with a plain container run plus inspect.

🤖 Generated with Claude Code

…ilder

Berthly's builder replica hard-coded DNSConfiguration(), whose default
nameserver is 1.1.1.1, so builds never used the network gateway's
resolver like CLI-made builders do, and ignored the [container.dns]
defaults container 1.7.1 added (apple/container#1614).

The builder now resolves DNS the way upstream's Builder.start does, and
DNS joins the reuse/recreate check using upstream's comparison so CLI
and Berthly builds don't recreate each other's builder. The first build
after updating recreates an existing 1.1.1.1 builder once, which drops
its build cache.
@henrywang henrywang added this to the v1.7.1 milestone Nov 12, 2026
@henrywang henrywang added the bug Something isn't working label Nov 12, 2026
@henrywang
henrywang merged commit 8b3109a into main Nov 12, 2026
7 checks passed
@henrywang
henrywang deleted the fix/builder-dns-defaults branch November 12, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: apply [container.dns] config defaults when Berthly starts the builder (container 1.7.1)

1 participant