Home > Enterprise >  Dockerfile not copying images folder to node-red directory
Dockerfile not copying images folder to node-red directory

Time:05-27

I want to copy some pictures to a folder in the node-red image, however it doesn't seem to work even though other COPY commands work.

FROM nodered/node-red AS base

USER root

COPY package.json /data/

COPY flows.json /data/
COPY img/ /data/
COPY new_settings.js /data/settings.js


CMD ["npm", "start", "--cache", "/data/.npm", "--", "--userDir", "/data", "--settings new_settings.js"]

The img/ is in the same directory as the other files that I copy, new_settings.js and flows.json. The logs don't report any error but everytime I go and check if the files are there, they are nowhere to be found.

This is my folder hierachy:

- node-red
    img
  Dockerfile
  flows.json
  new_settings.js
  package.json

To check if the files are there, I am using docker Desktop which allows me to go directly to the CLI of the image. There I access the data folder by running the command cd /data/ and then ls to see all files.

CodePudding user response:

When you map a volume to /data like you do, you hide everything in the image in that path and replace it with whatever is in the volume you map to it.

To see the data in the image, you can't map a volume to /data.

For more info, see the second bullet point here: https://docs.docker.com/storage/#tips-for-using-bind-mounts-or-volumes

  • Related