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

无法在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 Linux环境下CA证书更新问题
  • ¥15 sqlserver语句提取结果以外数据
  • ¥60 微信小程序如何上传QQ聊天文件
  • ¥300 开发的系统遭到无良商家的破解,请问如何防止再次发生,并追回损失
  • ¥15 java代码写在记事本上后在cmd上运行时无报错但又没生成文件
  • ¥15 关于#python#的问题:在跑ldsc数据整理的时候一直抱这种错误,要么--out识别不了参数,要么--merge-alleles识别不了参数(操作系统-linux)
  • ¥15 PPOCRLabel
  • ¥15 混合键合键合机对准标识
  • ¥100 现在不懂的是如何将当前的相机中的照片,作为纹理贴图,映射到扫描出的模型上
  • ¥15 安卓OpenCV人脸识别分类器加载