Get startedGet started for free

Understanding multi-stage builds

After successfully creating a multi-stage build, you want to make sure you understand the steps involved when actually running the docker build command.

Use the Dockerfile from the multi-stage build to follow the instructions below.

FROM golang:1.21 as gobuild

WORKDIR /src
COPY src/main.go /src/main.go

# Build the go application from source code
RUN go build -o /bin/app_runner /src/main.go

FROM scratch

COPY --from=gobuild /bin/app_runner /bin/app_runner

CMD ["/bin/app_runner"]

This exercise is part of the course

Intermediate Docker

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise