MulaiMulai sekarang secara gratis

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"]

Latihan ini adalah bagian dari kursus

Intermediate Docker

Lihat Kursus

Latihan interaktif praktis

Ubah teori menjadi tindakan dengan salah satu latihan interaktif kami.

Mulai berolahraga