Answers: <p>The final image will have all the layers from <code>diamol/base</code> as well as two additional layers - one for COPY and one for RUN command.</p>
  <p>File <code>/build.txt</code> will have the following contents:</p>
  <pre><code>Building...
  Testing...
  Done...
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-08-25T18:48:17.960Z
Answers: 2020-08-25T18:48:17.960Z
Answers: Konrad Botor
Body: <p>Below is the dockerfile that creates an image:</p>
  <pre><code>FROM diamol/base AS build-stage                  
  RUN echo 'Building...' &gt; /build.txt             
  
  FROM diamol/base AS test-stage
  COPY --from=build-stage /build.txt /build.txt
  RUN echo 'Testing...' &gt;&gt; /build.txt              
  
  FROM diamol/base
  COPY --from=test-stage /build.txt /build.txt
  RUN echo 'Done...' &gt;&gt; /build.txt               
  </code></pre>
  <p>and my understanding is, the final image consists layers of diamol/base and the layer created after the last RUN command as picture below shows:
  <a href="https://i.sstatic.net/TE7Z5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TE7Z5.png" alt="enter image description here" /></a></p>
  <p>Is my understanding correct?</p>
  
Comments: CC BY-SA 4.0
Comments: 2020-09-10T07:10:22.217Z
Comments: Multiply posted at https://stackoverflow.com/q/63578999/340790 .
Comments: JdeBP
Tags: <docker>
Title: what's the final output image in multistage build?
UserDisplayName: amjad
ThreadText: # what's the final output image in multistage build?
  
  (Asked by: username_0 on 2020-08-25)
  
  Below is the dockerfile that creates an image:
  
  ```
  FROM diamol/base AS build-stage                  
  RUN echo 'Building...' > /build.txt             
  
  FROM diamol/base AS test-stage
  COPY --from=build-stage /build.txt /build.txt
  RUN echo 'Testing...' >> /build.txt              
  
  FROM diamol/base
  COPY --from=test-stage /build.txt /build.txt
  RUN echo 'Done...' >> /build.txt               
  
  ```
  
  and my understanding is, the final image consists layers of diamol/base and the layer created after the last RUN command as picture below shows:
  [![enter image description here](https://i.sstatic.net/TE7Z5.png)](https://i.sstatic.net/TE7Z5.png)
  
  Is my understanding correct?
  
  **Tags:** docker
  
  > **Comments:**
  > **username_1**: Multiply posted at https://stackoverflow.com/q/63578999/340790 .  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-08-25. Score: 1
  
  The final image will have all the layers from `diamol/base` as well as two additional layers - one for COPY and one for RUN command.
  
  File `/build.txt` will have the following contents:
  
  ```
  Building...
  Testing...
  Done...
  
  ```
  
  
  ---
  
  