Stages can be built in parallel when using BuildKit
build1
and build2
are built at the same time
FROM alpine AS build1
RUN touch /opt/binary1
FROM alpine AS build2
RUN touch /opt/binary2
FROM alpine AS final
COPY --from=build1 /opt/binary1 /opt/
COPY --from=build2 /opt/binary2 /opt/
Concurrency is determined based on the dependency graph
–
Stages have a delay
Build sequentially using the legacy build engine:
time docker build .
Build in parallel using BuildKit:
DOCKER_BUILDKIT=1 docker build .
Sequential build will take double the time
Parallel builds reduce the waiting time