Bug 1843232 - Unable to build multi-stage image that has a --from=X that matches FROM X
Summary: Unable to build multi-stage image that has a --from=X that matches FROM X
Keywords:
Status: CLOSED DUPLICATE of bug 1844596
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Containers
Version: 4.5
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 4.6.0
Assignee: Tom Sweeney
QA Contact: weiwei jiang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-02 20:27 UTC by Clayton Coleman
Modified: 2020-08-19 21:05 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: buildah did not correctly handle COPY --from=X instructions if the --from option referenced an image Consequence: Multistage Dockerfile images fail to build Fix: buildah updated to copy from an image as well as a build step Result: Multistage Dockerfile builds of this type succeed
Clone Of:
: 1844596 1845345 (view as bug list)
Environment:
Last Closed: 2020-08-19 21:05:36 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Clayton Coleman 2020-06-02 20:27:24 UTC
One of our tests is a multistage build

FROM scratch as test
USER 1001
FROM %[1]s
COPY --from=test /usr/bin/curl /test/
COPY --from=%[1]s /bin/echo /test/
COPY --from=%[1]s /bin/ping /test/

where %[1]s is "image-registry.openshift-image-registry.svc:5000/openshift/tools:latest"

This fails with 

STEP 5: COPY --from=image-registry.openshift-image-registry.svc:5000/openshift/tools:latest /bin/echo /test/
error: build error: error building at STEP "COPY --from=image-registry.openshift-image-registry.svc:5000/openshift/tools:latest /bin/echo /test/": the stage "image-registry.openshift-image-registry.svc:5000/openshift/tools:latest" has not been built

which is not correct. --from implies image OR stage by name.  I tried to run


FROM scratch as test
USER 1001
FROM %[1]s as other
COPY --from=test /usr/bin/curl /test/
COPY --from=%[1]s /bin/echo /test/
COPY --from=%[1]s /bin/ping /test/

and it still failed.

There was an attempted fix in https://github.com/containers/buildah/pull/2321, but it either didn't make it into 4.5/master or may not cover the whole problem.

Marked as 4.5, this needs to be fixed and backported potentially to 4.4.

Comment 2 Adam Kaplan 2020-06-05 18:00:55 UTC
This did not make it to 4.5/master - this merged in buildah master, but is not available in a v1.14.z stream. Openshift/builder currently uses buildah v1.14.2 [1].

Moving this to the Containers team so that we get this backported to buildah v1.14.z, and cloning to ensure this gets into builds.

[1] https://github.com/openshift/builder/blob/release-4.5/go.mod

Comment 3 Tom Sweeney 2020-07-02 20:09:12 UTC
Upstream PR at:  https://github.com/containers/buildah/pull/2401.  Vendoring underway with this PR: https://github.com/openshift/builder/pull/160


Note You need to log in before you can comment on or make changes to this bug.