I'm building a multistage Docker image of a golang microservice and I want to make it very thin using busybox as base image to run the final executable. The image is correctly built, but when I run it I get this error:
standard_init_linux.go:211: exec user process caused "no such file or directory"
I'm working on my Ubuntu laptop, so this error has nothing to do with the Windows OS as many other questions report.
This is my image.
# build stage
FROM golang:1.15.3 AS build-stage
RUN mkdir /build
ADD . /build/
WORKDIR /build
RUN go mod download
RUN go test ./...
RUN go build -o goapp .
# final stage
FROM busybox
WORKDIR /app
COPY --from=build-stage /build/goapp /app/
CMD ["./goapp"]
A very simplified version of my project folder could be:
project
├── Dockerfile
├── go.mod
├── go.sum
├── main.go
└── other-packages