QuestionQ28

Verified702.3 Container Image Building

If a Dockerfile includes the following lines:

WORKDIR /test -  
  
USER root -  
  
RUN cd /tmp -  
  
RUN echo test > test.txt -  

Where is test.txt located?

Explanation

WORKDIR /test sets /test as the working directory for later RUN instructions. Each RUN instruction executes as a separate build step, so the cd /tmp change does not persist to the following step. The relative redirect target test.txt is consequently created at /test/test.txt in the container image.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!