Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Set up DNS names for Windows default network #47375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

robmry
Copy link
Contributor

@robmry robmry commented Feb 12, 2024

- What I did

Fixes #47370

- How I did it

DNS names were only set up for user-defined networks. On Linux, none of the built-in networks (bridge/host/none) have built-in DNS, so they don't need DNS names.

But, on Windows, the default network is "nat" and it does need the DNS names.

This is meant as a minimal change that we can ship in a patch if we make one ... but we probably need a better predicate to determine whether a container's going to get an internal resolver, here and elsewhere.

- How to verify it

As described in #47370.

Also, without the fix, in inspect output ...

"DNSNames": null

And, with the fix ...

"DNSNames": [
    "container1",
    "ac0225674b22"
]

Will also need a regression test.

- Description for the changelog

Restore DNS names for containers in the default "nat" network on Windows.

DNS names were only set up for user-defined networks. On Linux, none
of the built-in networks (bridge/host/none) have built-in DNS, so they
don't need DNS names.

But, on Windows, the default network is "nat" and it does need the DNS
names.

Signed-off-by: Rob Murray <rob.murray@docker.com>
@robmry robmry self-assigned this Feb 12, 2024
@robmry robmry added kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. area/networking area/networking/dns version/25.0 process/cherry-pick/25.0 labels Feb 12, 2024
@robmry robmry marked this pull request as ready for review February 12, 2024 21:16
@robmry robmry requested a review from corhere February 12, 2024 21:17
Copy link
Contributor

@corhere corhere left a comment

Choose a reason for hiding this comment

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

I hate it, but you're right; it's the best we can do with the (horribly named and underspecified) predicates we have at our disposal.

@thaJeztah
Copy link
Member

Honestly, I wonder if this was ever intentional. As the design for the default network (at least for "bridge" on Linux, for which "nat" is the equivalent on Windows), was to have no discovery, and to require --link to allow containers to resolve other containers by (host)name.

Preserving the existing behavior, at least for now, seems sane, but we should look when this "feature" was introduced, and if it was intentional or not.

@thaJeztah thaJeztah added this to the 26.0.0 milestone Feb 13, 2024
// Set up DNS names for a user defined network, and for the default 'nat'
// network on Windows (IsBridge() returns true for nat).
if containertypes.NetworkMode(n.Name()).IsUserDefined() ||
(serviceDiscoveryOnDefaultNetwork() && containertypes.NetworkMode(n.Name()).IsBridge()) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we ever hit the default network here (so not "nat")?

// IsDefault indicates whether container uses the default network stack.
func (n NetworkMode) IsDefault() bool {
return n == network.NetworkDefault
}

Wondering if we should include a link to the github discussion here for future reference 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to get "default" as far as this, but couldn't - so, decided not to add it. I couldn't see any problem with adding it just-in-case but, because I couldn't test it, I left it out and made a change targeted as specifically as possible at the issue being fixed. (Maybe libnetwork has a surprise to spring with "default", it usually does!)

For the github link ... I think the comment probably covers it, and git-blame is there if needed. But, could do?

As noted in the description, we need a follow-up change to clean this up properly - probably by adding a better predicate and looking at where else it should be used (and what the consequences would be). For example, I think the test in setupPathsAndSandboxOptions for whether to use systemd's resolv.conf also uses IsUserDefined as a proxy for "has internal resolver", so it suffers a similar problem... swarm-scoped networks, which do have an internal resolver, end up using systemd's underlying nameservers instead of 127.0.0.53... I think they miss the IsUserDefined() case by having the name default when it matters. I think that's probably an oversight but, as-ever, changing it might break things.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, maybe the default is not an issue (but I'm definitely not a fan of that magic value 😂 #19421)

Adding a link is not a real show-stopper for me; was mostly considering if we wanted to have a crumble-path to find back the discussion around this (basically; this is really a bit of a stop-gap, pending a more solid definition of all of this).

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

let's go with what we have now, but indeed let's create a tracking ticket for further discussion. This was clearly under-defined (and inconsistent between Windows and Linux)

@robmry
Copy link
Contributor Author

robmry commented Feb 13, 2024

Issue to track improvement of the predicates used here and elsewhere ... #47378

@robmry robmry deleted the 47370_windows_nat_network_dns branch February 13, 2024 14:21
@robmry robmry added kind/bugfix PR's that fix bugs and removed kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. labels Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal DNS does not work under Windows Server 2022 since version 25.0.0
5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.