Why docker working directory isn’t affected

enter image description here

As you see I have a directory called node-web-app inside it I have two directories

  • the second one called workdir
  • the first one called app which contain nodejs code, and I want dockerizing it

this is my Dockerfile

FROM node:10

WORKDIR /d/project/node-web-app/workdir

COPY package.json ./
COPY yarn.lock ./
RUN yarn

COPY . .


CMD [ "yarn", "start" ]

as I understand this commands COPY RUN CMD will be executed in the specified working directory

(in my case the working directory called workdir which is the second directory in node-web-app and its path is /d/project/node-web-app/workdir )

when I build the image from that Dockerfile the build done successfully, after that I checked the specified working directory (/d/project/node-web-app/workdir). the problem is it doesn’t have app files which should be copied using COPY command.

my question is this problem: bug in docker or my understanding of WORKDIR command is wrong?

Source: StackOverflow