Good morning, I just started using the new BuildKit to improve our build times by parallelising tasks. After some initial good progress, I’m facing an issue which I can’t explain. I simplified my Dockerfile a lot (see below), but I still don’t get it. I expected to see concurrent builds for all four images. However, it starts with
four and once those are completed, it will do all the remaining once in parallel (regardless how many there are in between). It seems like the order in the final image instructions are causing this order. Whatever comes last gets builds along with the first image, but why?
# Image one FROM alpine as one RUN mkdir -p /opt/one/ RUN sleep 5 # Image two FROM alpine as two RUN mkdir -p /opt/two/ RUN sleep 5 # Image three FROM alpine as three RUN mkdir -p /opt/three/ RUN sleep 5 # Image four FROM alpine as four RUN mkdir -p /opt/four/ RUN sleep 5 # Image Final FROM alpine:latest COPY --from=one /opt/one /opt/one COPY --from=two /opt/two /opt/two COPY --from=three /opt/three /opt/three COPY --from=four /opt/four /opt/four