fix(docker): windows container (#1710)

* Update ciwindows.Dockerfile
This commit is contained in:
Kyle Sanderson 2024-09-09 01:18:31 -07:00 committed by GitHub
parent 80426e4773
commit e603b262f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 11 deletions

View file

@ -130,6 +130,15 @@ func (c *AppConfig) writeConfig(configPath string, configFile string) error {
// but there's a good chance this is an isolated namespace
// or a container.
host = "0.0.0.0"
} else if user := os.Getenv("USERNAME"); user == "ContainerAdministrator" || user == "ContainerUser" {
/* this is the correct code below, but golang helpfully Panics when it can't find netapi32.dll
the issue was first reported 7 years ago, but is fixed in go 1.24 where the below code works.
*/
/*
u, err := user.Current(); err == nil && u != nil &&
(u.Name == "ContainerAdministrator" || u.Name == "ContainerUser") {
// Windows conatiners run containers as ContainerAdministrator by default */
host = "0.0.0.0"
} else if pd, _ := os.Open("/proc/1/cgroup"); pd != nil {
defer pd.Close()
b := make([]byte, 4096)