Docker Community Forums

Share and learn in the Docker community.

Standard_init_linux.go:195: exec user process caused "no such file or directory"


(Jchavannes) #1

Using a FROM scratch container I am getting this error:

standard_init_linux.go:195: exec user process caused "no such file or directory"

My dockerfile is simple:

FROM scratch
ADD main /
CMD ["/main"]

main is a go binary. It works just fine with a hello world app, but fails for larger projects.

I built the go binary using these flags:


And I’ve also tried adding -ldflags '-w -extldflags "-static"'

The binary is building just fine and works in a regular Linux container.

This error message doesn’t give me much of a clue what might be the error. Any ideas what would be causing a file to not be found in such a simple dockerfile?

(Sam) #2

scratch doesn’t have the go runtime?? maybe

(Jchavannes) #3

A compiled static binary doesn’t need the go runtime. Also, as I mentioned, a simple app (e.g. hello world) works fine.

(Sam) #4

i would docker attach to the container and look around to see what the problem might be…

i understand about static libraries, but clearly something is different with this executable.

(Jchavannes) #5

Thanks for the reply. This is a FROM scratch container so you cannot attach in. Also, there is only 1 file, main which is clearly added in the Dockerfile.

I’m confused why this would be an issue with the executable, the error I am getting is with Docker not being able to find a file. This seems like a Docker bug. Is there somewhere I should report it?

(Richard Lander) #6

Try building your go binary with GOARCH=386 in addition to GOOS=linux.

(Vladkras) #7

I had exactly the same problem. I ended up with configuring my repo (because I’m using both Windows and Linux for work)

git config --global core.eol lf
git config --global core.autocrlf input

cloning it again (not sure this step is needed) and building go executable with env vars

$ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build

I used before. Now

FROM scratch

COPY go-app /


CMD ["/go-app"]

works. Check this github issue too

(Javahuang) #8

this help me with CGO_ENABLED=0

(Olamo) #9

Same as @javahuang - once I did this it worked:

export CGO_ENABLED=0

(I was building golang executable on Ubuntu and trying to run inside Alpine-based container)