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?

Rohith
  • 2,043
  • 1
  • 17
  • 42

1 Answers1

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)

Rohith
  • 2,043
  • 1
  • 17
  • 42
  • Well done on solving the issue. Please accept your own answer – W.K.S Jan 08 '18 at 07:24
  • 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 :) – wasil Dec 01 '20 at 12:38
  • 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). – Dois Nov 26 '21 at 08:49