I am trying to run a very simple go/gin program on golang:alpine docker image. This fails to run/build.
Run container:
docker run -it --rm golang:1.10.1-alpine sh
In the container paste:
apk update && apk add git gcc musl-dev
go get github.com/gin-gonic/gin
cat <<EOT > src/main.go
package main
import _ "github.com/gin-gonic/gin"
func main() {
}
EOT
go run src/main.go
The error:
# command-line-arguments
2018/04/06 18:07:33 invalid symbol version for "go.string.\"aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a3855\xdb\x0f\x849\x0e\x00\x00H\x8b[\bH\x83\xfb\x01\x0f\x8f\x17\x00\x00H\x8bH H\x85\xc9\x0f\x84\x01": -7
Host Machine: macOS High Sierra 10.13.3, MacBook Pro Mid 2014, Intel i5
Docker version:
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:06:22 2018
OS/Arch: darwin/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:14:32 2018
OS/Arch: linux/amd64
Experimental: false
This works without error on golang/stretch image, though:
✗ dk run -it --rm golang:1.10.1-stretch bash 11:24AM
root@5d98f42504c2:/go# go get github.com/gin-gonic/gin
root@5d98f42504c2:/go#
root@5d98f42504c2:/go# cat <<EOT > src/main.go
> package main
> import _ "github.com/gin-gonic/gin"
> func main() {
> }
> EOT
root@5d98f42504c2:/go#
root@5d98f42504c2:/go# go run src/main.go
root@5d98f42504c2:/go#
What could be going wrong with alpine? Any suggestion is appreciated.
More Information
Same error with CGO disabled.
This is a build time failure and with -x option fails at:
EOF
mkdir -p $WORK/b001/exe/
cd .
/usr/local/go/pkg/tool/linux_amd64/link
-o $WORK/b001/exe/a.out
-importcfg $WORK/b001/importcfg.link
-buildmode=exe
-buildid=UZcMyOX9lILP9hahS-FF/kCN0nlKO7qaS5D1mwkHf/i8lsdHfkhJNsud-tI68Q/UZcMyOX9lILP9hahS-FF
-extld=gcc /root/.cache/go-build/55/55d1e3d2979a75ff5a13bc75c855482f90c32615d3b9e9d42ed096051efec200-d
# command-line-arguments
2018/04/06 21:28:17 invalid symbol version for "go.string.\"aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e0
82542a3855\xdb\x0f\x849\x0e\x00\x00H\x8b[\bH\x83\xfb\x01\x0f
\x8f\x17\x00\x00H\x8bH H\x85\xc9\x0f\x84\x01": -7