Interview Prep/Docker/Dockerfile Instructions & Builds

What does `WORKDIR` do and why prefer it over `RUN cd`?

IntermediateConceptDockerfile Instructions & Builds
Answer

WORKDIR sets the working directory for subsequent RUN, CMD, ENTRYPOINT, COPY, ADD and creates it if missing. RUN cd /x only affects that one RUN shell. Use absolute paths.

All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds