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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序