Skip to content

Add TOML configuration for default DNS nameservers, search, options - #1614

Open
0xMH wants to merge 4 commits into
apple:mainfrom
0xMH:fix/1449-dns-defaults
Open

0xMH wants to merge 4 commits into
apple:mainfrom
0xMH:fix/1449-dns-defaults

Conversation

@0xMH

@0xMH 0xMH commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Type of Change

  • New feature

Motivation and Context

Closes #1449. Adds default values for --dns, --dns-search, --dns-option, and --dns-domain to the [dns] section of ~/.config/container/config.toml, so users hitting macOS mDNSResponder conflicts can set the workaround once instead of repeating it on every invocation. Depends on the merged TOML configuration introduced by #1425.

Defaults are read by container run, container build, and container builder start via a shared Utility.dnsConfiguration(from:defaults:) helper. CLI flags take precedence; --no-dns still disables DNS. Two pre-existing bugs in the build path were fixed to make the feature work end-to-end: BuildCommand was forwarding only dnsNameservers to the builder (now forwards all four DNS fields), and BuilderStart's dnsChanged check only compared the first non-empty field (now compares all four).

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

Comment thread Sources/ContainerPersistence/ContainerSystemConfig.swift Outdated
@0xMH
0xMH force-pushed the fix/1449-dns-defaults branch 2 times, most recently from 6af7693 to b010238 Compare May 31, 2026 22:56
@0xMH
0xMH requested a review from katiewasnothere June 1, 2026 18:45
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

Code Coverage

Tier Line Coverage
Unit 34.55%
Integration 19.69%
Combined 53.62%

@0xMH
0xMH force-pushed the fix/1449-dns-defaults branch 2 times, most recently from 3eb0a7e to 46bd18b Compare June 3, 2026 23:29
@0xMH

0xMH commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @katiewasnothere. Happy to iterate further if anything else needs addressing.

@katiewasnothere katiewasnothere added this to the 2026-06 milestone Jun 3, 2026
@katiewasnothere

Copy link
Copy Markdown
Contributor

Hi @0xMH thank you for all the work you've done on this change! We are planning to make a new release of the container package some time in the next week and we want to hold off on merging this change until then.

@am-saksham

Copy link
Copy Markdown

Hi @0xMH and @katiewasnothere! First, thanks for the great work figuring out the core logic for this.

I noticed this PR has been stalled since the June release and has picked up some merge conflicts. I also saw that a couple of newer PRs for #1449 were opened recently, but they seem to have missed the [dns] vs [container.dns] architectural requirement that Katie pointed out above.

@0xMH, if you are currently swamped with other things, would you mind if I pull your branch, resolve the conflicts against main, and open a fresh PR to get this over the finish line? I will carry over your commits and make sure to include a Co-authored-by tag so you keep full credit for your work.

Let me know if that sounds good!

@0xMH

0xMH commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the offer! but no need since I'm waiting for the green flag to continue and rebase and prepare for the merge.

@am-saksham

Copy link
Copy Markdown

Awesome, sounds good! Looking forward to seeing it merged. Let me know if you end up needing a hand later on!

@jglogan jglogan removed this from the 2026-06 milestone Jul 7, 2026
@katiewasnothere

Copy link
Copy Markdown
Contributor

@0xMH Really sorry for the delay here, we've been swamped. I'd love to get this in for this sprint (which ends at the end of August). Could you rebase your PR? I will take another pass through the code. Thank you for your work here!

Comment thread docs/command-reference.md Outdated
- `192.168.*.*`
- `172.16.*.*` through `172.31.*.*`
- The host ends with the machine's default container DNS domain (as defined in `DNSConfig.defaultDomain`, located [here](../Sources/ContainerPersistence/ContainerSystemConfig.swift))
- The host ends with the machine's configured internal DNS domain from `[dns].domain`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a link to the reference doc here instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is now not relevant because the documentation was reorganized in PR #2032. The DNS settings are now documented here right?

public static func dnsConfiguration(
from flags: Flags.DNS,
defaults: ContainerDNSConfig,
hostDomainFallback: String? = nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This to preserve the existing behavior. hostDomainFallback uses [dns].domain only when no --dns-domain flag or [container.dns].domain is set. I added tests for the fallback and for container specific override

Comment on lines +155 to +157
public let nameservers: [String]
public let searchDomains: [String]
public let options: [String]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making these optionals instead of empty arrays?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I made them optional.


public let cpus: Int
public let memory: MemorySize
public let dns: ContainerDNSConfig

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making this an optional as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I made ContainerConfig.dns optional as well.

@jglogan

jglogan commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

@0xMH I'm Scrubbing through some of the PRs that fell through the cracks. When you can, can you rebase and address the PR review feedback? Thanks!

@0xMH
0xMH force-pushed the fix/1449-dns-defaults branch from 46bd18b to 606c4d4 Compare October 5, 2026 23:58
@0xMH
0xMH force-pushed the fix/1449-dns-defaults branch from 606c4d4 to 5b9e784 Compare October 6, 2026 07:07
@0xMH

0xMH commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

I rebased the branch and addressed the comments. Please let me know if there’s anything else to address.

This branch has not been deployed

No deployments
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.

[Request]: system property for default --dns.

4 participants