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"]
Cet exercice fait partie du cours
Intermediate Docker
Exercice interactif pratique
Passez de la théorie à la pratique avec l’un de nos exercices interactifs
 Commencer l’exercice
Commencer l’exercice