Docker container could not execute an executable binary

Hello team, I have the following in my Dockerfile

WORKDIR /test
RUN curl <link for some executable binary> --output <executable_binary_name>
COPY <config for binary> .
RUN chmod +x <executable_binary_name>
CMD ["./<executable_binary_name>", "--config", "<executable_config_file_name>"]

But the Docker container won’t run because could not execute ./<executable_binary_name>: fork/exec ./<executable_binary_name>: no such file or directory . I tried it with CMD ["/test/<executable_binary_name>", "--config", "/test/<executable_config_file_name>"] but it still couldn’t execute. I ran those commands individually on my terminal and they all work fine. I’m able to download the binary, I’m able to make it an executable, and I’m able to run the executable. But I’m not sure why they won’t work in a Docker container. Can someone please help me with this issue?

You might want to test if the curl command actualy downloaded the binary. Create your container with docker run -ti --rm --entrypoint /bin/sh <yourimagename>, then execute `ls -l /test’ and check if the filesize matches your expectation… if the size matches, try to execute it, if it’s too small, try to cat it.

I created the container with your command and ran ‘ls -l /test’. I am able to see the binary and the config file with their appropriate file sizes. However, when I try to execute the binary, it says /bin/sh: ./<executable_binary_name>: not found. I don’t understand. The file is right there and it is executable.

I was able to resolve the issue. Thank you.

Please share your solution, as it might be usefull for someone stumbling accross this thread.

The issue was that I was using an incorrect docker component from my company’s repository. The above Dockerfile should work in general cases.

1 Like