arrow_back
Back

Dockerfile WORKDIR: setting the working directory

Andrew Dorokhov Andrew Dorokhov schedule 1 min read

WORKDIR sets the working directory for any subsequent RUN, CMD, ENTRYPOINT, COPY, and ADD instructions. It can be used multiple times; relative paths are resolved against the previous WORKDIR.

If the directory does not exist, Docker creates it even if no later instruction uses it.

Example:

WORKDIR /var/node
RUN npm install
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Dockerfile VOLUME: declaring mount points

arrow_forward