mediumStudy question · answer published in Docker interview questions, so no pointsdockercontainer-security
Why use multi-stage builds
What is the main benefit of this multi-stage Dockerfile?
FROM golang:1.23 AS build WORKDIR /src COPY . . RUN CGO_ENABLED=0 go build -o /out/app ./cmd/app FROM gcr.io/distroless/static-debian12 COPY --from=build /out/app /app USER nonroot ENTRYPOINT ["/app"]
Discussion 0
Join free to post in the discussion.
Related questions
- Ordering Dockerfile steps for cachingDevOps Engineer
- Image vs containerDevOps Engineer
- Why use a .dockerignore fileDevOps Engineer
- Container exits right after startDevOps Engineer
- Why use a minimal base imageDevOps Engineer
- When to scan container imagesDevOps Engineer
- ENV password in a DockerfileDevOps Engineer
- CMD vs ENTRYPOINTDevOps Engineer