go: cmd/go: build inside a Windows container does not find the sources in mounted volume
What version of Go are you using (go version
)?
go version go1.8beta2 windows/amd64
What operating system and processor architecture are you using (go env
)?
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\gopath
set GORACE=
set GOROOT=c:\go
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
What did you do?
If possible, provide a recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best.
I tried to compile Go sources inside a Windows container by mounting the sources from the Windows Docker host into the Windows container.
On the Windows Docker host I did:
mkdir test
cd test
notepad webserver.go
docker run -it -v "$(pwd):C:\code" golang:1.8-nanoserver powershell
Now inside the PowerShell session in the Windows container I did:
cd c:\code
go build webserver.go
What did you expect to see?
It should find the Go source in the folder C:\code and build it.
I know there is https://github.com/golang/go/issues/15978 with the fix https://github.com/golang/go/commit/e65bce7144dbced232df8842ef6825d7e45f094e in Go 1.8. That’s why I tried it with the latest version.
What did you see instead?
PS C:\code> go build webserver.go
go build command-line-arguments: c:\go\pkg\tool\windows_amd64\compile.exe: chdir \ContainerMappedDirectories\F12A85AF-6803-4A43-A97B-BAFA93BDC334: The system cannot find the path specified.
Some more details about the mounted volume / reparse point C:\code
in the container:
PS C:\> cmd /c dir
Volume in drive C has no label.
Volume Serial Number is 1A3C-1F59
Directory of C:\
01/07/2017 01:35 AM <SYMLINKD> code [\\?\ContainerMappedDirectories\F12A85AF-6803-4A43-A97B-BAFA93BDC334]
01/07/2017 01:36 AM <DIR> go
01/07/2017 01:35 AM <DIR> gopath
11/20/2016 03:32 AM 1,894 License.txt
01/07/2017 01:35 AM <DIR> Program Files
07/16/2016 04:09 AM <DIR> Program Files (x86)
01/07/2017 01:35 AM <DIR> Users
01/07/2017 01:41 AM <DIR> Windows
1 File(s) 1,894 bytes
7 Dir(s) 21,231,828,992 bytes free
PS C:\> fsutil reparsepoint query c:\code
Reparse Tag Value : 0xa000000c
Tag value: Microsoft
Tag value: Name Surrogate
Tag value: Symbolic Link
Reparse Data Length: 0x00000116
Reparse Data:
0000: 00 00 80 00 82 00 86 00 00 00 00 00 5c 00 43 00 ............\.C.
0010: 6f 00 6e 00 74 00 61 00 69 00 6e 00 65 00 72 00 o.n.t.a.i.n.e.r.
0020: 4d 00 61 00 70 00 70 00 65 00 64 00 44 00 69 00 M.a.p.p.e.d.D.i.
0030: 72 00 65 00 63 00 74 00 6f 00 72 00 69 00 65 00 r.e.c.t.o.r.i.e.
0040: 73 00 5c 00 46 00 31 00 32 00 41 00 38 00 35 00 s.\.F.1.2.A.8.5.
0050: 41 00 46 00 2d 00 36 00 38 00 30 00 33 00 2d 00 A.F.-.6.8.0.3.-.
0060: 34 00 41 00 34 00 33 00 2d 00 41 00 39 00 37 00 4.A.4.3.-.A.9.7.
0070: 42 00 2d 00 42 00 41 00 46 00 41 00 39 00 33 00 B.-.B.A.F.A.9.3.
0080: 42 00 44 00 43 00 33 00 33 00 34 00 00 00 5c 00 B.D.C.3.3.4...\.
0090: 5c 00 3f 00 5c 00 43 00 6f 00 6e 00 74 00 61 00 \.?.\.C.o.n.t.a.
00a0: 69 00 6e 00 65 00 72 00 4d 00 61 00 70 00 70 00 i.n.e.r.M.a.p.p.
00b0: 65 00 64 00 44 00 69 00 72 00 65 00 63 00 74 00 e.d.D.i.r.e.c.t.
00c0: 6f 00 72 00 69 00 65 00 73 00 5c 00 46 00 31 00 o.r.i.e.s.\.F.1.
00d0: 32 00 41 00 38 00 35 00 41 00 46 00 2d 00 36 00 2.A.8.5.A.F.-.6.
00e0: 38 00 30 00 33 00 2d 00 34 00 41 00 34 00 33 00 8.0.3.-.4.A.4.3.
00f0: 2d 00 41 00 39 00 37 00 42 00 2d 00 42 00 41 00 -.A.9.7.B.-.B.A.
0100: 46 00 41 00 39 00 33 00 42 00 44 00 43 00 33 00 F.A.9.3.B.D.C.3.
0110: 33 00 34 00 00 00 3.4...
PS C:\>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (7 by maintainers)
Commits related to this issue
- Add test for golang/go#18555 — committed to StefanScherer/dockerfiles-windows by StefanScherer 7 years ago
- Merge pull request #131 from StefanScherer/golang-issue-18555 Add test for golang/go#18555 — committed to StefanScherer/dockerfiles-windows by StefanScherer 7 years ago
- os: reimplement windows os.Stat Currently windows Stat uses combination of Lstat and Readlink to walk symlinks until it reaches file or directory. Windows Readlink is implemented via Windows DeviceIo... — committed to golang/go by alexbrainman 7 years ago
A suitable build environment would be a Windows Server 2016 machine in GCE, Azure …
If there is no template with Docker preinstalled, you can follow the docs to install Docker on a Windows Server 2016
Such a server can build Docker images based on these two base images:
So if you want to have a look into Nano Server, using Docker would be easier than maintaining a Nano Server directly. But on Azure there also is a Nano Server VM available.
The issue with the symlink to
\\?\ContainerMappedDirectories\uuid
is also heavily discussed in docker/docker#27537 as it affects other languages as well.