Uploaded image for project: 'Product Technical Learning'
  1. Product Technical Learning
  2. PTL-15531

DO188v4.18:Ch04s04: Clarify that WORKDIR is NOT preserved between multistages

XMLWordPrintable

    • Icon: Story Story
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • DO188 - RHOCP4.18-en-3-20250829
    • DO188
    • False
    • Hide

      None

      Show
      None
    • False
    • 4
    • en-US (English)

      Please fill in the following information:


      URL: https://role.rhu.redhat.com/rol-rhu/app/courses/do188-4.18/pages/ch04s04 
      Reporter RHNID: acancell@redhat.com 
      Section Title:     Guided Exercise: Build Images with Advanced Containerfile Instructions                                                                    

      Issue description: 

       Clarify that WORKDIR is NOT preserved between multistages

      Example:
      ~~~
      FROM registry.access.redhat.com/ubi9/ubi:9.5 AS first
      WORKDIR /opt
      RUN pwd # == /opt
      RUN echo test > test.txt # is saved on /opt/test.txt

      FROM registry.access.redhat.com/ubi9/ubi:9.5
      RUN pwd # == “/” That is, WORKDIR is NOT preserved between multistages, but “starts” again form default “/”

      1. COPY --from=first test.txt /opt/test.txt # WRONG The file on the left would be searched from the “new” WORKDIR, that is in /test.txt
        COPY --from=first /opt/test.txt /opt/test.txt # CORRECT
        ENTRYPOINT ["sleep"]
        CMD ["infinity"]

       

      Steps to reproduce:

       

      Workaround:

       

      Expected result:

              asernabo@redhat.com Alejandro Serna-Borja
              chetan-rhls Chetan Tiwary
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: