• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

docker 容器上编译 go 程序提示找不到文件问题

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

dockerfile

[root@SZB-L0010091 zxg]# cat Dockerfile
FROM scratch
COPY webdemo /
EXPOSE 9999
CMD ["/webdemo"]

docker run 报错信息:

[root@zxg]# docker run --rm -it -p 9999:9999 web:1.0
panic: standard_init_linux.go:178: exec user process caused "no such file or directory" [recovered]
  panic: standard_init_linux.go:178: exec user process caused "no such file or directory"

goroutine 1 [running, locked to thread]:
panic(0x6f2340, 0xc420132620)
  /usr/lib/golang/src/runtime/panic.go:500 +0x1a1
github.com/urfave/cli.HandleAction.func1(0xc420091748)
  /builddir/build/BUILD/docker-1398f249013601ab999d286910664d70fd1329a2/runc-f5721697226d42d9efeea37fa3a7eb1d208fa1a2/Godeps/_workspace/src/github.com/urfave/cli/app.go:478 +0x247
panic(0x6f2340, 0xc420132620)
  /usr/lib/golang/src/runtime/panic.go:458 +0x243
github.com/opencontainers/runc/libcontainer.(*LinuxFactory).StartInitialization.func1(0xc420091198, 0xc42001e050, 0xc420091238)
  /builddir/build/BUILD/docker-1398f249013601ab999d286910664d70fd1329a2/runc-f5721697226d42d9efeea37fa3a7eb1d208fa1a2/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:259 +0x18f
github.com/opencontainers/runc/libcontainer.(*LinuxFactory).StartInitialization(0xc42004efa0, 0xaab9c0, 0xc420132620)
  /builddir/build/BUILD/docker-1398f249013601ab999d286910664d70fd1329a2/runc-f5721697226d42d9efeea37fa3a7eb1d208fa1a2/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:277 +0x353
main.glob..func8(0xc4200ba3c0, 0x0, 0x0)
  /builddir/build/BUILD/docker-1398f249013601ab999d286910664d70fd1329a2/runc-f5721697226d42d9efeea37fa3a7eb1d208fa1a2/main_unix.go:26 +0x66
reflect.Value.call(0x6dd0c0, 0x768ec8, 0x13, 0x73b509, 0x4, 0xc420091708, 0x1, 0x1, 0x4d17a8, 0x731360, ...)
  /usr/lib/golang/src/reflect/value.go:434 +0x5c8
reflect.Value.Call(0x6dd0c0, 0x768ec8, 0x13, 0xc420091708, 0x1, 0x1, 0xac1700, 0xc4200916e8, 0x4da786)
  /usr/lib/golang/src/reflect/value.go:302 +0xa4
github.com/urfave/cli.HandleAction(0x6dd0c0, 0x768ec8, 0xc4200ba3c0, 0x0, 0x0)
  /builddir/build/BUILD/docker-1398f249013601ab999d286910664d70fd1329a2/runc-f5721697226d42d9efeea37fa3a7eb1d208fa1a2/Godeps/_workspace/src/github.com/urfave/cli/app.go:487 +0x1e0
github.com/urfave/cli.Command.Run(0x73b6d5, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74cc8a, 0x51, 0x0, ...)
  /builddir/build/BUILD/docker-1398f249013601ab999d286910664d70fd1329a2/runc-f5721697226d42d9efeea37fa3a7eb1d208fa1a2/Godeps/_workspace/src/github.com/urfave/cli/command.go:191 +0xc3b
github.com/urfave/cli.(*App).Run(0xc4200cc000, 0xc420064060, 0x2, 0x2, 0x0, 0x0)
  /builddir/build/BUILD/docker-1398f249013601ab999d286910664d70fd1329a2/runc-f5721697226d42d9efeea37fa3a7eb1d208fa1a2/Godeps/_workspace/src/github.com/urfave/cli/app.go:240 +0x611
main.main()
  /builddir/build/BUILD/docker-1398f249013601ab999d286910664d70fd1329a2/runc-f5721697226d42d9efeea37fa3a7eb1d208fa1a2/main.go:137 +0xbd6

解决办法:增加-tags netgo选项编译

GOOS=linux GOARCH=amd64 go build -tags netgo -o rollingupdate${TAG} main.go

总结

以上所述是小编给大家介绍的好的docker 容器上编译 go 程序无法运行提示找不到文件问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对极客世界网站的支持!


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
CoreOS配置Docker镜像加速器的方法发布时间:2022-02-12
下一篇:
Vmware虚拟机启动按F2无法进入BIOS画面的解决方法发布时间:2022-02-12
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap