Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1843232

Summary: Unable to build multi-stage image that has a --from=X that matches FROM X
Product: OpenShift Container Platform Reporter: Clayton Coleman <ccoleman>
Component: ContainersAssignee: Tom Sweeney <tsweeney>
Status: CLOSED DUPLICATE QA Contact: weiwei jiang <wjiang>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.5CC: adam.kaplan, aos-bugs, dwalsh, ealcaniz, erich, jokerman, tsweeney, wzheng
Target Milestone: ---   
Target Release: 4.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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
Story Points: ---
Clone Of:
: 1844596 1845345 (view as bug list) Environment:
Last Closed: 2020-08-19 21:05:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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