[PR #2075] [MERGED] fix: network-scoped alias is supported only for containers in user defined networks #2259

Closed
opened 2026-03-01 21:54:41 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/2075
Author: @ChristopherHX
Created: 11/2/2023
Status: Merged
Merged: 11/12/2023
Merged by: @mergify[bot]

Base: masterHead: fix-network-scoped-alias-regression


📝 Commits (2)

  • 0cd4b67 fix:
  • a006b92 Merge branch 'master' into fix-network-scoped-alias-regression

📊 Changes

1 file changed (+3 additions, -1 deletions)

View changed files

📝 pkg/container/docker_run.go (+3 -1)

📄 Description

This Windows only issue is caused by the missing !n.IsHost() in the n.IsUserDefined() function for windows. Act sends the network alias for the host network on windows, linux sees that and calls the same IsUserDefined (but uses the unix definition on the server side), which detects the host network as non user defined network.

On linux and macOS it is impossible to reproduce at the time of creating this change. I don't get why windows has it's own definition, but bad maintained.

The actual code uses IsUserDefined to detect if network aliases are supported, which didn't work on windows due to the mess in the docker client go library.

Thank you docker client.

go\pkg\mod\github.com\docker\docker@v24.0.7+incompatible\api\types\container\hostconfig_unix.go

// IsUserDefined indicates user-created network
func (n NetworkMode) IsUserDefined() bool {
	return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer()
}

go\pkg\mod\github.com\docker\docker@v24.0.7+incompatible\api\types\container\hostconfig_windows.go

// IsUserDefined indicates user-created network
func (n NetworkMode) IsUserDefined() bool {
	return !n.IsDefault() && !n.IsNone() && !n.IsBridge() && !n.IsContainer()
}

Why did docker this?

Seems like we have to replace the convenience function with it's unix definition

Important bug fix, I don't have the power


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/2075 **Author:** [@ChristopherHX](https://github.com/ChristopherHX) **Created:** 11/2/2023 **Status:** ✅ Merged **Merged:** 11/12/2023 **Merged by:** [@mergify[bot]](https://github.com/apps/mergify) **Base:** `master` ← **Head:** `fix-network-scoped-alias-regression` --- ### 📝 Commits (2) - [`0cd4b67`](https://github.com/nektos/act/commit/0cd4b674e24dc0332215d108ef3074f2238ca073) fix: - [`a006b92`](https://github.com/nektos/act/commit/a006b92f3a18263de5f9cd9fc9232f8b23b9ab95) Merge branch 'master' into fix-network-scoped-alias-regression ### 📊 Changes **1 file changed** (+3 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `pkg/container/docker_run.go` (+3 -1) </details> ### 📄 Description This Windows only issue is caused by the missing `!n.IsHost()` in the `n.IsUserDefined()` function for windows. Act sends the network alias for the host network on windows, linux sees that and calls the same `IsUserDefined` (but uses the unix definition on the server side), which detects the `host` network as non user defined network. On linux and macOS it is impossible to reproduce at the time of creating this change. I don't get why windows has it's own definition, but bad maintained. The actual code uses `IsUserDefined` to detect if network aliases are supported, which didn't work on windows due to the mess in the docker client go library. Thank you docker client. go\pkg\mod\github.com\docker\docker@v24.0.7+incompatible\api\types\container\hostconfig_unix.go ``` // IsUserDefined indicates user-created network func (n NetworkMode) IsUserDefined() bool { return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() } ``` go\pkg\mod\github.com\docker\docker@v24.0.7+incompatible\api\types\container\hostconfig_windows.go ``` // IsUserDefined indicates user-created network func (n NetworkMode) IsUserDefined() bool { return !n.IsDefault() && !n.IsNone() && !n.IsBridge() && !n.IsContainer() } ``` Why did docker this? Seems like we have to replace the convenience function with it's unix definition **Important bug fix, I don't have the power** --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 21:54:41 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#2259
No description provided.