Q: 2
Which of the following statement is INCORRECT with respect to a Dockerfile?
Options
Discussion
Option A
Doesn't the Dockerfile syntax doc say WORKDIR sets context for COPY and ADD only if the source path is relative? So A is wrong unless all paths are absolute, then it wouldn't matter. This edge case gets missed in most practice tests.
A WORKDIR does set the dir for COPY and ADD too. Pretty sure that's it but feel free to correct me.
A , because WORKDIR also affects COPY and ADD as per Docker docs, so it's the incorrect statement here. Quick check in practice matches this too. Unless I'm missing some build context detail?
C or D for me. RUN does stack layers and commits, so C looks legit, but I've always seen ENTRYPOINT and CMD in shell form too, not just JSON. D seems less likely to be wrong but I'm second guessing myself. If anyone's got a solid source let me know if I'm missing something.
A is definitely the incorrect one here. WORKDIR sets the directory for COPY and ADD as well, not just RUN, CMD, ENTRYPOINT. Seen this pop up in a few practice sets. Pretty sure about it but if anyone's seen a weird edge case let me know.
B tbh. ENV seems off since it's not always used the way they're saying, kinda traps folks on wording.
A is incorrect. WORKDIR applies to COPY and ADD too, not just RUN, CMD, ENTRYPOINT. Docker uses the set directory for all these build steps. Pretty sure this matches both docs and what I've seen in labs, but happy for corrections.
Yeah, A is the incorrect one here. WORKDIR sets the working directory for COPY and ADD as well, not just RUN, CMD, ENTRYPOINT. Dockerfile behavior is pretty consistent that way. I think that's what trips most people up on this type of question, unless someone has seen otherwise?
A for sure, WORKDIR does influence COPY and ADD, not just RUN, CMD, ENTRYPOINT. Dockerfile basics. Seen this phrasing trip up folks before. Pretty confident but open if anyone sees a counterexample.
Be respectful. No spam.