Skip to content

bug: buildkit does not consider ONBUILD COPY --from #816

@astorath

Description

@astorath

Hi, we make heavy use of ONBUILD option in our environment.

Our typical Dockerfile looks like this:

FROM my.company.com/ci/dotnet:v1-build as build
FROM my.company.com/ci/dotnet:v1-runtime

This works fine in legacy docker build, but turning on BUILDKIT option activates some optimizations, so docker tries to build these containers in parallel. The problem is containers are dependent:

  1. my.company.com/ci/dotnet:v1-build:

    FROM base:v1
    WORKDIR /src
    ONBUILD COPY . /src
    ONBUILD make clean all
  2. my.company.com/ci/dotnet:v1-runtime:

    FROM runtime:v1
    WORKDIR /app
    ONBUILD COPY --from=build /src/target /app

Running DOCKER_BUILDKIT=1 docker build . results in:

DOCKER_BUILDKIT=1 docker build .
[+] Building 0.8s (8/8) FINISHED
...
 => ERROR [stage-2 3/1] COPY --from=build /src/target/ /app 0.0s
------
 > [stage-2 3/1] COPY --from=build /src/target/ /app:
------
 not found: not found

My questions are:

  1. Can I turn off these optimizations to run builds sequentially?
  2. Is there a way to mark these stages as dependent explicitly?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions