1

I'm building my go program in WSL (bash on windows), mounting the output folder as a volume in a centos docker container and attempting to run the program. When attempting to run the program like so:

docker exec -it <container-instance> /bin/sh
# ./<program-name>

I get:

/bin/sh: ./<program-name>: not found

What gives?

1 Answer 1

5

Initially, I thought that the problem was because I was compiling the go program for the wrong architecture. It was being compiled for amd64. When I tried compiling it for 386 (with GOARCH=386) it seemed to start up. On further investigation, the container was running centos 64 bit (checked using uname -m and getconf LONG_BIT). Finally the solution that worked is setting CGO_ENABLED=0 before compiling (see here)

Sign up to request clarification or add additional context in comments.

3 Comments

Well done on solving the issue. Please accept your own answer
Maybe someone will find it helpful: in my case, I had multi stage Dockerfile in which first stage was building Go executable which was afterwards copied and run in second stage. Problem was that first stage used Debian-based image, and the second - Alpine based. After using same image for both stages, everything started to work without any additional settings :)
I had the exact same issue as you guys. Thank you so much guys for posting your solutions (in my case, my first build stage was Alpine and the second stage was Debian).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.