10

go程序在alpine镜像里无法正常运行

 3 years ago
source link: https://studygolang.com/articles/32280?fr=sidebar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

go程序在alpine镜像里无法正常运行

seecsea · 大约4小时之前 · 14 次点击 · 预计阅读时间不到 1 分钟 · 不到1分钟之前 开始浏览    

[root@spray2:~]# kubectl logs -f client-go-in-cluster-demo
standard_init_linux.go:211: exec user process caused "no such file or directory"
.
非常简单的Dockerfile
[root@omp-harbor:/data/Dockerfile/k8stest]# vim Dockerfile
FROM alpine:3.12.3

COPY ./app /app
CMD ["/app"]
.
搞了半天,其实是alpine镜像的问题:
https://stackoverflow.com/a/62123648
.

CGO has to be disabled for alpine

export CGO_ENABLED=0
Then go build
.

All OK啦!!!!


有疑问加站长微信联系(非本文作者)

280

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:1006366459


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK