doupingtang9627 2018-01-06 04:52
浏览 402
已采纳

无法在docker / bin / sh内部运行go程序:<程序>:未找到

I'm building my go program in WSL (bash on windows), mounting the output folder as a volume in a centos docker container and attempting to run the program. When attempting to run the program like so:

docker exec -it <container-instance> /bin/sh
# ./<program-name>

I get:

/bin/sh: ./<program-name>: not found

What gives?

  • 写回答

1条回答 默认 最新

  • dongyong2906 2018-01-06 04:53
    关注

    Initially, I thought that the problem was because I was compiling the go program for the wrong architecture. It was being compiled for amd64. When I tried compiling it for 386 (with GOARCH=386) it seemed to start up. On further investigation, the container was running centos 64 bit (checked using uname -m and getconf LONG_BIT). Finally the solution that worked is setting CGO_ENABLED=0 before compiling (see here)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波