If a Dockerfile contains the following lines:
WORKDIR /
RUN cd /tmp
RUN echo test > test
where is the file test located?
Suggested Answer: C
Get Premium 305-300 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
33 comments · newest first
SH
Shawnda
11 months ago
No way it's in /root, that's just wrong!
MA
Martha
11 months ago
I thought it would be in /tmp, but I guess not.
JO
Joni
12 months ago
Wait, how can it be in /tmp if the WORKDIR is set to /?
ST
Stevie
12 months ago
Yeah, definitely /test.
AN
An
1 year ago
It's in the root directory, so /test.
LI
Lisbeth
1 year ago
I feel like the file is created in `/tmp`, but I might be mixing it up with how volumes work in Docker.
ME
Melodie
1 year ago
I practiced a similar question where the file ended up in the working directory, but I can't recall if that applies here.
JA
Jacinta
1 year ago
I remember something about the RUN command not changing the working directory for subsequent RUN commands, so maybe it's in `/tmp`?
GA
Gabriele
1 year ago
I think the file should be in the root directory since the WORKDIR is set to `/`, but I'm not entirely sure.
FI
Filiberto
1 year ago
Ah, I see now. The WORKDIR sets the working directory, but the RUN cd /tmp command doesn't actually change the working directory for the subsequent RUN command. The test file will be located at /test within the container image. Nice!
SH
Shala
1 year ago
I think I've got it! The WORKDIR sets the working directory to /, and the RUN echo test > test command creates the test file in the / directory. So the correct answer is /test within the container image.
AL
Alayna
1 year ago
Wait, I'm a bit confused. If the WORKDIR is set to /, then the RUN cd /tmp command shouldn't change the working directory, right? I'm not sure where the test file is located.
KA
Kate
1 year ago
Okay, let's see. The WORKDIR command sets the working directory to /, and then the RUN cd /tmp command changes the directory to /tmp. So the test file should be in /tmp, right?
KI
King
1 year ago
Hmm, this one seems tricky. I'll need to carefully read through the Dockerfile instructions to figure out where the test file is located.
NI
Nieves
2 years ago
Ah, the age-old question of where the file test is located. It's like a game of hide-and-seek, but with Docker commands instead of children.
MI
Micaela
2 years ago
Haha, the file test is actually located in the secret dimension of the container, where it will only be visible to the chosen ones. All the other options are mere distractions!
LE
Lenita
2 years ago
I'm pretty sure the file test is located in /test within the container image. The WORKDIR command should have set the working directory to / before running the RUN commands.
RA
Raelene
2 years ago
Option D is correct. The RUN cd /tmp command changes the directory to /tmp, but it doesn't change the working directory. So, the file test is created in /tmp/test on the system running the Docker build.
JO
Johana
2 years ago
E) test in the directory holding the Dockerfile.
JA
Jacquline
2 years ago
D) /tmp/test on the system running docker build.
PR
Princess
2 years ago
C) /test within the container image.
DE
Delisa
2 years ago
B) /root/tesc within the container image.
LE
Levi
2 years ago
A) /ting/test within the container image.
IZ
Izetta
2 years ago
I'm not sure, but I think it might be in /ting/test within the container image.
TA
Tasia
2 years ago
I believe it's actually in /tmp/test on the system running docker build.
SH
Shelba
2 years ago
I think the file test is located in /tmp/test.
CL
Claribel
2 years ago
The file test is located in /tmp/test within the container image. The WORKDIR command sets the working directory to /, and the RUN cd /tmp command changes the directory to /tmp before running echo test > test.
VI
Vicente
2 years ago
D) /tmp/test on the system running docker build.
AR
Arthur
2 years ago
C) /test within the container image.
JU
Juan
2 years ago
B) /root/tesc within the container image.
HE
Herman
2 years ago
A) /ting/test within the container image.
SE
Serina
2 years ago
D) /tmp/test on the system running docker build.
MI
Mirta
2 years ago
A) /ting/test within the container image.