mstruebing
mstruebing

Reputation: 1802

cant execute binary inside docker container but from host machine

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?

Upvotes: 2

Views: 642

Answers (1)

mstruebing
mstruebing

Reputation: 1802

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

Upvotes: 3

Related Questions