Skip to content

Commit 63158f7

Browse files
authored
Merge pull request docker#6801 from thaJeztah/no_no_netgo
scripts/build/.variables: don't use "netgo" when building Windows binaries
2 parents 7b93d61 + 2fa6b73 commit 63158f7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scripts/build/.variables

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ]; then
102102
# compiling statically with CGO enabled requires osusergo and netgo to be set.
103103
GO_BUILDTAGS="$GO_BUILDTAGS osusergo netgo"
104104
fi
105+
# XXX: Disable netgo on Windows and use Windows system resolver instead.
106+
#
107+
# go1.19 and newer added support for netgo on Windows (https://go.dev/doc/go1.19#net),
108+
# which may not respect VPN adaptors (such as Twingate) due to resolver ordering,
109+
# resulting in queries being sent through the local network adapter instead of the
110+
# VPN tunnel. See https://github.com/docker/cli/issues/6665
111+
if [ "$(go env GOOS)" = "windows" ]; then
112+
GO_BUILDTAGS=$(echo "$GO_BUILDTAGS" | sed 's/\(^\| \)netgo\( \|$\)/\1/g')
113+
fi
105114
if [ -n "$GO_STRIP" ]; then
106115
# if stripping enabled and building with llvm < 12 against darwin/amd64
107116
# platform, it will fail with:

0 commit comments

Comments
 (0)