Node-RED & dockerfile, can make folder, cannot add text file to it?

HI,

I know not so many use docker and I am a beginner, but I am totally stuck !

My dockerfile ...

FROM  nodered/node-red:3.1.3

RUN mkdir -p /data/gb/test

WORKDIR /data/gb/test

COPY test.txt /data/gb/test

This does create the folders in Node-RED /data folder.

But when I type into CLI ... docker compose up -d I get his error ?

Error response from daemon: 
failed to create task for container: failed to create shim task: 
OCI runtime create failed: runc create failed: unable to start container process: 
exec: "./entrypoint.sh": stat ./entrypoint.sh: no such file or directory: unknown

Thanks

Do you need to use docker? If not then don't.

HI Colin,

I understand what you say, I have it all working, just some minor things like this are very frustrating.
I have Node-RED, Grafana, Sqlite and even Postrgres if I want to use that, all working in Docker desktop .

I originally took the docker route because i thought it would be easy to deploy and modify for my home automation project. mostly it is easy, but when I have spent all of yesterday trying to get this to work, it is not.

If I do

WORKDIR /usr/src/node-red
COPY test.txt .

This does work and creates the text file in that dir, but I cannot get it into /data ?

:roll_eyes:

Why are you setting workdir ? Should be fine just to create your directory and copy into it without changing workdir

Hi dceejay,

I believe I did try that, but as I have tried so many things i maybe wrong ?

https://nodered.org/docs/getting-started/docker

I have just re-read this section as I do have an external directory with package.json etc...

Dockerfile which copies in local resources
It can sometimes be useful to populate a Node-RED Docker image with files from a local directory (for example, if you want a whole project to be kept in a git repo). To do this, you’ll want your local directory to look like this:

Dockerfile
README.md
package.json # add any extra nodes your flow needs into your own package.json.
flows.json # the normal place Node-RED store your flows
flows_cred.json # credentials your flows may need
settings.js # your settings file
NOTE: This method is NOT suitable if you want to mount the /data volume externally. If you need to use an external volume for persistence then copy your settings and flows files to that volume instead.

So perhaps i cannot do what I am trying to do, but I think I still had to do ... npm install in docker with the above.
So I thought it would be easier to do everything with a dockerfile and then I could include npm install in the dockerfile.

I have been working on this until late last night, so I am tired and a little confused as to what i have done :roll_eyes:

Sorry

It seems from the error message that entrypoint.sh cannot be found.

What happens if you added

WORKDIR /usr/src/node-red

at the end of your dockerfile?

I second @dceejay advise not to change WORKDIR at all.

Hi all,

I am going to pause this topic, as I spent 10 hours yesterday trying to get this to work and for some reason now I cannot even create my folders in /data

I was able to do this yesterday, but I am not sure how as I have done the same today and it does not work.

I am going to start a new topic, this time showing you what I want to do, as I may have been doing this all wrong as I am a beginner in using Docker and Docker desktop .

This time ask your advice on the best way :+1:

Thanks so far for your help.

Im runnng several NR environments on my docker environment. There are a few pre-requisites in my setup.
(i'm running Grafana, InfluxDB,mqtt,HA and others in parallel containers)

Tools

  1. I'm running WEBMIN on my machine. This will simplify the managment of resources (mapping folders to NAS, create additional IP adresses, etc). It was just helpful :wink: to avoid the usual LINUX comand line setup
  2. I'm using PORTAINER to manage my docker environment

Setup of DATA folder (seperate DATA folder required for every NR instance)

  1. your should create a data folder outside your NR structuer (mkdir /NR/Data01 or so) ... or if you have a NAS you can generate a mountpoint with WEBMIN (here /mnt/TS/NR mounted to my shared NAS folder on 192.168.2.240)

Setup the new NR environment/instance

  1. Create a new docker container with PORTAINER
  2. Ensure you have different PORT numbers (here default 1880 ..i use 2880 and 3880 for my 2nd and 3rd NR instances) for each NR instance
  3. Update the environment variables (it will reduce some issues later :wink: )
  • Set variable PORT to 1880 (it has to be the same number as in 3)
  • Set variable TZ to your timezone setting (otherwise your timers in NR will be incorrect)
  • Set variable NODE_RED_ENABLE_SAFE_MODE to false or true....to disable or enable safe mode

Map the DATA folder to your NR environment/instance

  1. setup the DATA folder in PORTAINER
    image
  • make sure you have /data defined (this is the same for each NR instance)
  • map the /data folder to the NR folder of this instance (here /mnt/TS/NR) .. same folder as you created in 1)
    --> Data-Folder --> Mount Point --> Local or remote stoarage path
    --> /data --> /mnt/TS/NR --> 192.168.2.240 /Public/hp02/new_nr

Now you should be able to deploy your docker based NR istance/environment.

The benefits of this way are:

  • you can have multiple NR instances running (just ensure you have individual PORT's and DATA folders defined)
  • you will have access to your DATA folder from outside the docker environment like windows file manager (no specific docker command required to access, edit, copy or backup your data) ... see mapping in 1)
  • your data can easily be stored on a remote NAS or other shared storage place
  • you can easily re-deploy the NR instance to maintain the latest version without risking your DATA
  • this template works on any docker system (raspberry or X86 based) .. you should be able to create a new NR environment in minutes
  • you can manage the NR environment via the GUI from PORTAINER and WEBMIN and other standard tools

I hope it will help you .. pls let me know if it does not work for you (maybe I have missed to describe a step)

1 Like

Hi xx_Nexus_xx

Thanks for all of that, it will take me some time to assess it all, today I plan to keep things fairly basic and just get the dockerfile working.

I am running Linux on my host PC so things maybe a little different.

I think I already have a similar structure as I have bind mounts to folders external to Docker.

03

I will look at WEBMIN & PORTAINER in the near future on Youtube, as that is how I learn best.

I am sure I will have to ask you much more in the future ( if that's ok ? ), but for now I am going to concentrate on getting one instance of Node-RED working in docker with my own Node-RED docker image ?

When you do it your way do you pre-populate the Manage palette menu ?

Thanks

I started a new post as the title needed to be changed to be more relevant and I changed exactly what I wanted to do going forwards.

Here is the new post

I did the manual bind as well (with Lunux cmd) but failed due to wrong or missing parameters. E.g. I was not able to edit or add files manually to the data folder.

Only when using WEBMIN, with these parameters (see screenshot in 1) I was able to fully use the remote NAS location as data drive for NR

I was doing the pre-populate for my test environment.

  1. created the new environment as described above
  2. than copy below files into my folder
  • flows.json
  • settings.json
  • package.json
  1. run npm install from within docker-terminal (here I use PORTAINER again)

this should create the nodes-modules folder with all your libraries required

I may have missed a step as I'm currently not at my machine :wink: .. have a try

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