Docker multi-stage builds

You probably don’t need the whole language toolchain in your Docker container. If you still want to use Docker to build you can use so-called multi-stage builds (official documentation ).

Example

This is an example for a Golang application:

FROM golang:1 AS builder
COPY /app /
WORKDIR /app
RUN go build -o /bin/app ./app

FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /bin/app .
CMD ["./app"]
Edit this page on GitHub