douye1876 2019-03-15 18:08
浏览 824
已采纳

无法在Docker容器中执行二进制文件,但从主机执行

I have a docker container based on composer:1.8(based on php:7-alpine).

Inside the container I download a tar.gz via php, decompress it and extract it which works fine. This contains a Go binary I want to execute. When executing the binary inside the docker container I get this error message: ./bin/<binary>: No such file or directory. On my host machine I can execute this binary downloaded inside the docker container perfectly fine.

If it is important I start the docker container with: docker run -it --rm --volume=$PWD:/usr/src/myapp -u $(id -u):$(id -g) --name ec ec /bin/bash

I also tried to run readelf -a <binary> after installing it, but that doesn't have any effect.

bash-4.4$ ls -l <binary> && echo userid: $(id -u) && echo groupid: $(id -g) && uname -om && ./<binary>
-rwxr-xr-x    1 1000     985        7582050 Mar 15 17:09 <binary>
userid: 1000
groupid: 985
x86_64 Linux
bash: ./<binary>: No such file or directory

What can I do to make this work?

  • 写回答

1条回答 默认 最新

  • duanchi3109 2019-03-16 08:56
    关注

    It's because the binary is compiled using glibc and alpine using musl. I've got around with it to pass my binary the CGO_ENABLED=0 environment variable while building

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

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿