Skip to content

Windows containers: report HNS network name in inspect#50961

Merged
thaJeztah merged 2 commits intomoby:masterfrom
robmry:windows_hns_network_name
Sep 16, 2025
Merged

Windows containers: report HNS network name in inspect#50961
thaJeztah merged 2 commits intomoby:masterfrom
robmry:windows_hns_network_name

Conversation

@robmry
Copy link
Contributor

@robmry robmry commented Sep 12, 2025

- What I did

After creating a new network, inspect shows that there's no value for option "com.docker.network.windowsshim.networkname". After restarting the daemon, it shows up with the docker network name (not the HNS network name, which defaults to the docker network's id).

Creating the network with "-o com.docker.network.windowsshim.networkname" sets the HNS network name, and it shows up in inspect. Until the daemon is restarted, then it shows the docker network name.

When Windows reboots, it deletes HNS networks. They're re-created from Docker's store, but the HNS network name is lost.

- How I did it

Set the option value to the HNS network name on creation (the id if no name is given), and on restore after restart use the name reported by HNS. On restore after reboot, preserve the HNS name recorded in Docker's driver-opts.

- How to verify it

docker network create -d nat n1
docker network create -d nat -o com.docker.network.windowsshim.networkname=n2name n2

Check com.docker.network.windowsshim.networkname reported in inspect is as-expected for each network (Docker's network id, and n2name), and that they match the HNS names (Get-HnsNetwork -id <hns id from inspect>).

Restart the daemon and check nothing changed.

Reboot and check the HNS network names are preserved, the HNS network ids will change.

- Human readable description for the release notes

- Windows: `network inspect`: the HNS network name is now reported in option `com.docker.network.windowsshim.networkname` rather than the Docker network name, which was only reported after a daemon restart.

After creating a new network, inspect shows that there's no value
for option "com.docker.network.windowsshim.networkname". After
restarting the daemon, it shows up with the docker network name
(not the HNS network name, which defaults to the docker network's
id).

Creating the network with "-o com.docker.network.windowsshim.networkname"
sets the HNS network name, and it shows up in inspect. Until the
daemon is restarted, then it shows the docker network name.

So - set the option value to the HNS network name on creation (the id
if no name is given), and on restore after restart use the name
reported by HNS.

Signed-off-by: Rob Murray <rob.murray@docker.com>
@robmry robmry self-assigned this Sep 12, 2025
@robmry robmry marked this pull request as ready for review September 12, 2025 16:24
@robmry robmry added this to the 29.0.0 milestone Sep 12, 2025
@thaJeztah
Copy link
Member

thaJeztah commented Sep 12, 2025

The HNS name seems to be reset on reboot, before starting dockerd, I'm not sure why.

I'm guessing that could be because the network is destroyed by Windows nowadays;

@robmry
Copy link
Contributor Author

robmry commented Sep 12, 2025

The HNS name seems to be reset on reboot, before starting dockerd, I'm not sure why.

I'm guessing that could be because the network is destroyed by Windows nowadays;

Oh, duh! Thank you, I didn't look closely enough ... so there's another bug, options aren't copied into the re-created network when restoring HNS networks from Docker's store. I'll zap that too.

When Windows reboots, it removes HNS networks. They're restored
from Docker's store (unlike after a daemon restart, where Docker
networks are restored from HNS networks).

When that happens, preserve the driver-opt that reports the HNS
network name when that happens.

Signed-off-by: Rob Murray <rob.murray@docker.com>
@robmry robmry requested a review from akerouanton September 12, 2025 20:12
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.

SGTM

@akerouanton PTAL (some changes after you last reviewed)

@thaJeztah
Copy link
Member

Let me bring this one in

@thaJeztah thaJeztah merged commit f230988 into moby:master Sep 16, 2025
326 of 328 checks passed
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.

com.docker.network.windowsshim.networkname network option is only populated on daemon reboot

4 participants