作为go应用存在二进制文件却不能执行

明明镜像中有对应的二进制文件,但是执行时却提示 not foundno such filestandard_init_linux.go:211: exec user process caused "no such file or directory"

网上常说都是因为windows换行符编码问题。此处实际问题是该二进制文件是使用动态链接方式编译.

解决方法:

CGO_ENABLED=0  GOOS=linux  GOARCH=amd64 go build --ldflags "-extldflags -static"

注意:CGO_ENABLED=0 GOOS=linux GOARCH=amd64cgo_enabled=0 goos=linux goarch=amd64 是有区别的。

保存信息

诸如此类信息都是上述问题

standard_init_linux.go:211: exec user process caused "no such file or directory"

/tmp # ./envoy_end 
/bin/sh: ./envoy_end: not found

替换为国内源

RUN sed -i 's@http://dl-cdn.alpinelinux.org/@https://mirrors.aliyun.com/@g' /etc/apk/repositories

相关文章: