Docker - Node Red - add and access additional volume

Good morning all.
I am running node-red in docker and want to share a text file outside of docker.
In the docker compose file I did

volumes:
- ./node_red_data:/data
- /home/server/docker/shared:/sharedfolder

I then placed a mytext.txt in the "/home/server/docker/shared" folder.

My assumption was/is that I would then be able to access the "/sharedfolder' within node red but when I try to write data to a text file I get the following error

"failed to append to file: Error: ENOENT: no such file or directory, open '/sharedfolder/mytext.txt'"

Writing to data to a /data/test.txt file works without a problem.
Am I accessing the folder/file incorrectly?

The error suggests you are trying to add to an existing file. Does it already exist?

[Edit] Oh I see you have said that you have put a file there. Are you sure you have named it correctly, I see you have said

which is test.txt not mytext.txt.

Otherwise I don't know. I prefer to avoid docker whenever practical.

1 Like

Hi Paulf007,

I access my files on my host PC using Bind mounts, that should solve your problem ?

Hello Paul,

I had the same issue with access or create files/folders on my NAS drive .. I made a small write-up on how to bind your NAS Shared-Drives to docker here

I hope it helps

Good morning all.

Thank you for all the feedback , I did some further reading as suggested and the solution seems to be that you need to "link" the folders within the /data/ folder so your docker compose should look like this.

volumes:
- ./node_red_data:/data
- /home/server/docker/shared:/data/sharedfolder

Then before you deploy the container create the folder 'sharedfolder' within the "node_red_data".
So you will have "/node_red_data/sharedfolder" on the real world.
I sort off expected for docker compose to do this but I am in no way an expert here and are just fiddling until I get it right :wink:
I have tested this, and it works. If you create a file in NR the file will be created in the " /home/server/docker/shared" directory , the "/node_red_data/sharedfolder" folder will remain empty.
Hope this will help someone later.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.