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

作者:_菜鸟的下划线_ 时间:2022-04-21 11:27:52 

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 程序无法运行提示找不到文件问题网站的支持!

来源:https://blog.csdn.net/zhangxiangui40542/article/details/80420736

标签:docker,容器,go,程序
0
投稿

猜你喜欢

  • 启用Mod Rewrite和.htaccess

    2010-06-03 14:56:00
  • “贼喊捉贼”优朋普乐被法院裁定第一盗版商

    2009-10-23 15:30:00
  • 百度收录更新无规律,个人草根“叫苦连天”

    2007-11-16 16:06:00
  • 网络诞生“威客族” 10万职业威客月均赚三千

    2009-10-23 14:04:00
  • 分析并清除web服务器上的网页木马

    2009-05-28 08:36:00
  • VMware vSphere所需要开放的端口清单

    2022-07-23 16:27:20
  • 土豆网总经理张晓运:视频网站应以内容为王

    2009-10-22 14:26:00
  • 在Windows IIS下配置WordPress MU环境

    2008-05-28 13:56:00
  • 关键词选择攻略 处理好冷热门及专业关系

    2009-02-18 12:21:00
  • linux增加iptables防火墙规则的示例

    2023-08-06 01:11:22
  • Google AdSense账号停止后:被滥用的愤怒与同情

    2007-11-23 17:12:00
  • 搜索引擎优化仅仅考虑搜索引擎还远远不够

    2008-12-18 10:30:00
  • Spider与crawler不同点

    2008-08-26 11:57:00
  • 用Windows Server 2003搭建安全文件服务器(2)

    2007-09-27 13:55:00
  • 建站经验:冷门行业网站站长应该如何坚守

    2009-01-07 14:18:00
  • 电影服务器相关网络协议简介

    2009-01-13 16:43:00
  • 怎样识别诈骗网站-网赚新手注意系列

    2010-05-10 15:18:00
  • adsense如何更改收款人姓名

    2008-03-16 15:30:00
  • MDaemon的安装入门篇

    2007-03-27 13:39:00
  • 被百度K站的十大诱因

    2007-11-04 18:42:00
  • asp之家 网站运营 m.aspxhome.com