Skip to content

dockercompat: key inspect Networks by real CNI network name - #5164

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
larrasket:fix-2999-inspect-network-names
Sep 8, 2026
Merged

AkihiroSuda merged 1 commit into
containerd:mainfrom
larrasket:fix-2999-inspect-network-names

Conversation

@larrasket

@larrasket larrasket commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

nerdctl inspect currently shows a container's networks as unknown-eth0 instead of the network name

It comes from networkSettingsFromNative in pkg/inspecttypes/dockercompat: the map key is built from the interface name with a hardcoded unknown- prefix, and it does not look at which network the interface belongs to. (There was already a // TODO: set CNI name when possible sitting there).

go-cni names the interfaces eth0, eth1, ... in the same order the networks were attached, and nerdctl keeps that ordered list in the nerdctl/networks annotation. I read the list from the annotation and map eth<i> back to networks[i].

If an interface doesn't fit that pattern, host networking, something not set up by CNI, or an older container with no annotation, it keeps the old unknown-<iface> key, so those cases are unchanged.

Added single, and multi-network cases to TestNetworkSettingsFromNative; the existing cases are untouched.

Fixes #2999

nerdctl inspect keyed NetworkSettings.Networks by a synthesized
"unknown-<iface>" name (e.g. "unknown-eth0") instead of the network the
endpoint actually belongs to.

go-cni names the i-th attached network's interface "eth<i>" in the order
the networks were configured, and that ordered list is recorded in the
nerdctl/networks spec annotation. Resolve each interface back to its
network name through that list, falling back to the previous
"unknown-<iface>" key when there is no match (host networking, an
interface not created by CNI, or a missing networks annotation).

Fixes containerd#2999

Signed-off-by: Saleh <root@lr0.org>
@AkihiroSuda AkihiroSuda added this to the v2.4.0 milestone Sep 8, 2026

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda
AkihiroSuda merged commit 644511f into containerd:main Sep 8, 2026
76 of 86 checks passed
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.

nerdctl inspect does not list networks name properly

2 participants