What is the point of WORKDIR on Dockerfile

0 votes

Docker is something I'm learning. I've seen the WORKDIR command in Dockerfile numerous times:

FROM node:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
EXPOSE 3000
CMD [ “npm”, “start” ] 

Isn't it possible to just leave out WORKDIR and Copy and have my Dockerfile at the root of my project? What are the drawbacks of this strategy?

Apr 29, 2022 in Docker by Abhijeet
• 180 points

edited 5 days ago 12 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP