Reputation: 504
Below is my dockerfile, I do a copy of js file in copy command and set working directory after that,followed by volume and run command.Below is my dockerfile 1) I understand node_modules(Which is created because of running npm install) IS getting wipedoff when container is first initialized because of create volume in the same location My quesion why my app.js which i copied in step 3 is not getting wiped of since its also on the same path as volume?
FROM node:latest
ENV NODE_ENV=production
ENV PORT=3000
COPY . /app
WORKDIR /app
VOLUME ["/app"]
RUN npm install
EXPOSE $PORT
ENTRYPOINT ["node","app.js"]
Upvotes: 1
Views: 59
Reputation: 19328
Q: Why is my app.js (which i copied in step 3) is not getting wiped off while node_modules
is.
A: As explained in docker's documentation under the volume section.
Quote:
Changing the volume from within the Dockerfile:
If any build steps change the data within the volume after it has been declared, those changes will be discarded.
Reference: https://docs.docker.com/engine/reference/builder/#notes-about-specifying-volumes
Upvotes: 1