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?
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)