0

I would like to run my node-js application in a docker instance, but at the same time, I would like to change some files (like .env or content-related files) without having to rebuild the docker-image. Currently, I build the image with this dockerfile:

FROM node:16
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm i --production
COPY . .
CMD ["node", "main.js"]

When I run the image on my Synology NAS I mounted a volume to the path /usr/scr/app`, but this does not change the behavior of the docker app. It seems that all node sources are already in the image (or are ignored).

My goal would be that the image only contains node modules and the source files (.js) would be supplied via a mounted volume.

How can I achieve this behavior?

snx
  • 33
  • 6
  • If you end goal is to run a Node interpreter over source code that lives on the host, you don't need Docker for this; installing Node directly and just running `node main.js` is probably simpler. – David Maze Dec 24 '22 at 12:00
  • I need docker because in the end-use it will run along with other docker containers in the cloud – snx Dec 24 '22 at 12:27
  • I think you can enter the container and change .env file or content-related files then you must restart the container – Xirehat Dec 24 '22 at 20:44

1 Answers1

0

for env look at How do I pass environment variables to Docker containers?

for other not code => move it folder and mount this folder via volume

Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88