MLGonc
MLGonc

Reputation: 99

Dockerfile ERROR: standard_init_linux.go:207: exec user process caused "no such file or directory

I'm having this error when trying to create service ERROR: standard_init_linux.go:207: exec user process caused "no such file or directory".. This does not happen when I use ubuntu:latest as base image.

So I try to run service with:

docker service create --name mon --publish 9999:9999 --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock mon:1 

And the service is not successfully created.

Here is my dockerfile with golang:alpine:

FROM golang:alpine
COPY . /edg
RUN chmod a+x /edg/edgmn
EXPOSE 9999
CMD ["/edg/edgmn", "--rules.reactive", "--swarm.environment", "--alert.address=X:9091"]

I've tried a lot of things but nothing works.

Any ideas? Thanks

Upvotes: 0

Views: 676

Answers (1)

chash
chash

Reputation: 4423

Your binary is likely dynamically linked against one or more libraries that is not available in the alpine image. For example, if your binary is linked to glibc (typical if you compiled it on Ubuntu), it will not work in alpine (which uses musl instead of glibc), but would work with ubuntu:latest.

See How do I build a static Go binary for the Docker Alpine image?

In short, compiling your binary with CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build <args> before copying it into the alpine container will often solve the problem.

Upvotes: 3

Related Questions