0

I am trying to learn more about containerization via creating a container image with docker for a demo program that I wrote in go. The image seems to build fine but when I go to run it I get this:

exec /com/zmanhobbies/dnsz/DNSZ: no such file or directory

from my docker run command:

docker run -p 53:8053 zacharyduve/dnsz:latest

I have tested that the executable works fine outside of the container on the same system. Also I have been able to open a sh session with docker run -i zacharyduve/dnsz:latest sh on the running container and verify that the executable is there as this is the result from my ls command

ls -las /com/zmanhobbies/dnsz/DNSZ

2228 -rwxr-xr-x 1 root root 2277627 Jul 19 13:37 /com/zmanhobbies/dnsz/DNSZ

Interesting is that I get the same not found error from the internal sh session when I try to run the executable that way as well. Through my experimentation I have been able to get a shell script loaded and to run fine but using the same formatting I haven't been able to get my executable to run. From the size of the image it seems like my executable is there. This is the content of my Dockerfile:

FROM alpine

COPY build/DNSZ /com/zmanhobbies/dnsz/DNSZ

CMD [ "/com/zmanhobbies/dnsz/DNSZ" ]

and I am building it along with the executable with this shell script in the same directory as the Dockerfile

export GOOS=linux

go build -o build/DNSZ DNSZ.go

docker build -t zacharyduve/dnsz:latest 

I am sure that the problem is between the keyboard and the chair but to me it seems like it all should be working just not sure why I am getting that it doesn't exist when a bunch of things point to it existing.

  • Alpine uses a different low-level C library stack, and there are known issues trying to run Go binaries that weren't specifically built for Alpine in an Alpine container. Does using a `debian` base image work better? Or can you use a multi-stage build to build the binary in Docker too? – David Maze Jul 19 '23 at 14:18
  • (Consider putting your binary in a "normal" location like `/usr/local/bin` and you won't need to spell out the full path in the `CMD`.) – David Maze Jul 19 '23 at 14:18
  • Thank you. Alpine turned out to be the issue as once I switched it to debian it started. From the error I didn't even consider to be the base image to be the issue. – Zachary Duve Jul 19 '23 at 14:38

0 Answers0