I'm trying to build a minimal docker image for go using this Dockerfile
FROM debian:stretch-slim AS builder
ENV VERSION 1.9.3.
ENV OS linux
ENV ARCH amd64
RUN apt update && apt upgrade -y && apt install -y curl
RUN curl -O -fsSL "https://dl.google.com/go/go$VERSION$OS-$ARCH.tar.gz" \
&& tar -C /usr/local -xzf "go$VERSION$OS-$ARCH.tar.gz"
RUN /usr/local/go/bin/go env
FROM scratch
ENV GOPATH=/code
ENV PATH=/usr/local/go/bin
COPY --from=builder /usr/local/go /usr/local/go
CMD ["/usr/local/go/bin/go"]
Building this image using docker build -t golang:1.9.3 .
. The output of the container is as follows, if executed like this docker run --rm -ti golang:1.9.3
:
standard_init_linux.go:195: exec user process caused "no such file or directory"
EDIT: I am aware of the golang images on docker hub like golang:alpine, which is ~265MB in size.