Skip to content

feature: Populate NetworkSettings.Gateway#4771

Open
must108 wants to merge 1 commit intocontainerd:mainfrom
must108:inspect-gateway
Open

feature: Populate NetworkSettings.Gateway#4771
must108 wants to merge 1 commit intocontainerd:mainfrom
must108:inspect-gateway

Conversation

@must108
Copy link

@must108 must108 commented Mar 5, 2026

Resolves #415

Issue

NetworkSettings.Gateway is expected to be present in inspect output. nerdctl did not expose this prior to this change, even when a default gateway existed.

Changes

This pull request adds a feature that allows for NetworkSettings.Gateway to be populated in nerdctl inspect output.

How it works:

  • Collects default IPv4 gateway from the container network namespace during netns inspection

  • Stores the gateway in inspect network data

  • Propagates the value to DefaultNetworkSettings.Gateway

  • Unit tests have also been adjusted to reflect this change.

Testing

go test ./pkg/containerinspector ./pkg/inspecttypes/dockercompat

Notes

  • I have limited the scope to only IPv4, but considered also implementing a solution for IPv6. I can create a new issue for this if it is deemed necessary.

Copy link
Member

@haytok haytok left a comment

Choose a reason for hiding this comment

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

Thanks for creating this PR! Would it be possible to have e2e tests using Tigron for this feature ?

@must108
Copy link
Author

must108 commented Mar 5, 2026

Thanks for creating this PR! Would it be possible to have e2e tests using Tigron for this feature ?

Good suggestion, thanks! I'll add a Tigron e2e test that verifies that NetworkSettings.Gateway is populated on inspect.

@must108
Copy link
Author

must108 commented Mar 5, 2026

@haytok added the test

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Please squash the commits

@must108 must108 force-pushed the inspect-gateway branch 3 times, most recently from fc3cd88 to c8e2272 Compare March 6, 2026 08:52
Copy link
Member

@haytok haytok left a comment

Choose a reason for hiding this comment

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

When checking this CI Log, the test TestContainerInspectGateway you have added has failed, so please check your fix.

=== Failing tests ===
TestContainerInspectGateway

@must108 must108 force-pushed the inspect-gateway branch 2 times, most recently from 63fd7ab to 2b0bd48 Compare March 7, 2026 10:31
Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

add test TestContainerInspectGateway

Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

Fix test issues

Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

Remove container.test

Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

Resolve review and tests

Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

feature: populate NetworkSettings.Gateway and add e2e coverage
Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

Resolve test issues

Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

feature: populate NetworkSettings.Gateway and add e2e coverage
Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

drop unrelated hostsstore changes

Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>

Change testing

feature: populate NetworkSettings.Gateway and add e2e coverage

Resolve breaking tests

Add gateway to docker inspect output

Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>
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.

Supporting Gateway in DefaultNetworkSettings in docker compatible inspect

3 participants