New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

LPI 305-300 Exam - Topic 4 Question 24 Discussion

Actual exam question for LPI's 305-300 exam
Question #: 24
Topic #: 4
[All 305-300 Questions]

If a Dockerfile contains the following lines:

WORKDIR /

RUN cd /tmp

RUN echo test > test

where is the file test located?

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

0/2000 characters
Shawnda
3 months ago
No way it's in /root, that's just wrong!
upvoted 0 times
...
Martha
3 months ago
I thought it would be in /tmp, but I guess not.
upvoted 0 times
...
Joni
3 months ago
Wait, how can it be in /tmp if the WORKDIR is set to /?
upvoted 0 times
...
Stevie
4 months ago
Yeah, definitely /test.
upvoted 0 times
...
An
4 months ago
It's in the root directory, so /test.
upvoted 0 times
...
Lisbeth
4 months ago
I feel like the file is created in `/tmp`, but I might be mixing it up with how volumes work in Docker.
upvoted 0 times
...
Melodie
4 months ago
I practiced a similar question where the file ended up in the working directory, but I can't recall if that applies here.
upvoted 0 times
...
Jacinta
4 months ago
I remember something about the RUN command not changing the working directory for subsequent RUN commands, so maybe it's in `/tmp`?
upvoted 0 times
...
Gabriele
5 months ago
I think the file should be in the root directory since the WORKDIR is set to `/`, but I'm not entirely sure.
upvoted 0 times
...
Filiberto
5 months 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!
upvoted 0 times
...
Shala
5 months 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.
upvoted 0 times
...
Alayna
5 months 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.
upvoted 0 times
...
Kate
5 months 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?
upvoted 0 times
...
King
5 months 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.
upvoted 0 times
...
Nieves
1 year 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.
upvoted 0 times
...
Micaela
1 year 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!
upvoted 0 times
...
Lenita
1 year 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.
upvoted 0 times
...
Raelene
1 year 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.
upvoted 0 times
Johana
1 year ago
E) test in the directory holding the Dockerfile.
upvoted 0 times
...
Jacquline
1 year ago
D) /tmp/test on the system running docker build.
upvoted 0 times
...
Princess
1 year ago
C) /test within the container image.
upvoted 0 times
...
Delisa
1 year ago
B) /root/tesc within the container image.
upvoted 0 times
...
Levi
1 year ago
A) /ting/test within the container image.
upvoted 0 times
...
...
Izetta
1 year ago
I'm not sure, but I think it might be in /ting/test within the container image.
upvoted 0 times
...
Tasia
1 year ago
I believe it's actually in /tmp/test on the system running docker build.
upvoted 0 times
...
Shelba
1 year ago
I think the file test is located in /tmp/test.
upvoted 0 times
...
Claribel
1 year 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.
upvoted 0 times
Vicente
1 year ago
D) /tmp/test on the system running docker build.
upvoted 0 times
...
Arthur
1 year ago
C) /test within the container image.
upvoted 0 times
...
Juan
1 year ago
B) /root/tesc within the container image.
upvoted 0 times
...
Herman
1 year ago
A) /ting/test within the container image.
upvoted 0 times
...
Serina
1 year ago
D) /tmp/test on the system running docker build.
upvoted 0 times
...
Mirta
1 year ago
A) /ting/test within the container image.
upvoted 0 times
...
...

Save Cancel