Go's Dockerfile journey

Creeping complexity in packaging Go with Docker

Published · Updated 10 Feb 2025

Once upon a time all you needed to Dockerize an app was the 2016 deprecated onbuild:

FROM golang:onbuild
EXPOSE 8080

Then we went multistage:

FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app
ENTRYPOINT ./app

Now distroless is said to be 50% smaller than Alpine, since it doesn’t have a shell, though distroless has:

https://github.com/GoogleContainerTools/distroless/blob/main/examples/go/Dockerfile

https://gist.github.com/MatthewJamesBoyle/598538dd1c8d38f9dc70575b1be5958a

Then often you need curl to run health checks.