docker官网pull的alpine镜像,是缺少musl-dev包的,这导致了相关glibstdc相关的编译缺少文件,如

loadinternal: cannot find runtime/cgo
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64- 
alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64- 
alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
collect2: error: ld returned 1 exit status

解决方案:确保你的Dockerfile包含 musl-dev 包,或者直接运行

apk add --no-cache musl-dev
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐