Bug 1784532 - Document `FROM` replacement behavior in multistage Docker builds
Summary: Document `FROM` replacement behavior in multistage Docker builds
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 4.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.4.0
Assignee: Adam Kaplan
QA Contact: wewang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-12-17 16:20 UTC by Adam Kaplan
Modified: 2020-05-04 11:20 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: `FROM` replacement in multistage dockerfile builds was not clear Consequence: developers may not understand how OpenShift manipulates the Dockerfile provided to a build Fix: clarified the text in our API and docs. Result: command line and online docs make it clear that the last FROM statement in a Dockerfile is changed if a developer provides a `from:` imagestream in their BuildConfig spec
Clone Of:
Environment:
Last Closed: 2020-05-04 11:20:24 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift api pull 583 0 None closed Bug 1784532: Clarify FROM behavior in builds 2020-07-03 03:05:35 UTC
Github openshift openshift-docs pull 19503 0 None closed Bug 1784532: Clarify FROM behavior in builds. 2020-07-03 03:05:34 UTC
Red Hat Product Errata RHBA-2020:0581 0 None None None 2020-05-04 11:20:58 UTC

Description Adam Kaplan 2019-12-17 16:20:56 UTC
Description of problem:

The current documentation provided online and in our CLI (via oc explain) does not indicate how Docker strategy builds will reference an imagetream in a multistage Dockerfile.

Docs and CLI should be updated to indicate that the last `FROM` statement in a multistage Dockerfile will be replaced.

Version-Release number of selected component (if applicable): 4.3.0

Comment 1 Stephen Cuppett 2019-12-17 19:50:03 UTC
Setting to active development branch for investigation (4.4). Clones will be created for prior releases where backports needed, if any.

Comment 3 wewang 2020-02-11 07:42:19 UTC
Verified in 
4.4.0-0.nightly-2020-02-09-193413

Steps:
1. Use bc to create a build 

kind: "BuildConfig"
apiVersion: v1
metadata: 
  name: multi-test
spec:
  source:
    dockerfile: |-
      FROM scratch as test
      USER 1001
      FROM centos:7
      COPY --from=test /usr/bin/curl /test/
      COPY --from=busybox:latest /bin/echo /test/
      COPY --from=busybox:latest /bin/ping /test/
  strategy:
    dockerStrategy:
      from: 
        kind: ImageStreamTag
        name: ruby:2.2
        namespace: openshift

2. Check the build log
[root@wangwen ~]# oc logs -f build/multi-test-1
Replaced Dockerfile FROM image centos:7
Caching blobs under "/var/cache/blobs".
Writing manifest to image destination
Storing signatures
STEP 1: FROM scratch AS test
STEP 2: USER 1001
a4d03bdf8e8d6125b084fefe2c9580ec739efabc29fa6f345e7690ba878c152d
STEP 3: FROM image-registry.openshift-image-registry.svc:5000/openshift/ruby@sha256:xxxx  ###the last `FROM` statement in a multistage Dockerfile is be replaced 
STEP 4: COPY --from=test /usr/bin/curl /test/

Comment 5 errata-xmlrpc 2020-05-04 11:20:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:0581


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