Coder Social home page Coder Social logo

Comments (5)

jthomas avatar jthomas commented on July 28, 2024

Yes, you can. If you build a new container image using this image with the FROM directive you can add the files into the filesystem.

These properties show you where and how the user configuration is set up:
https://docs.docker.com/engine/userguide/eng-image/baseimages/

from node-red-docker.

braghettos avatar braghettos commented on July 28, 2024

Hi @jthomas, thanks for your reply.

My Dockerfile is the following:

FROM nodered/node-red-docker:0.17.5-rpi

RUN npm install node-red-node-serialport xbee-api node-red-contrib-xbee node-red-contrib-chatbot node-red-node-twitter node-red-contrib-ibm-watson-iot node-red-contrib-play-audio

COPY ./config/flows.json /data/
COPY ./config/settings.js /data/

RUN ls -la /data/

And the output of the last 3 instructions is the following:

Step 3/5 : COPY ./config/flows.json /data/
---> 68a0a0dfd7bb
Removing intermediate container 48113b5a7153
Step 4/5 : COPY ./config/settings.js /data/
---> 4dae182466a1
Removing intermediate container 2fbab4ac3f1e
Step 5/5 : RUN ls -la /data/
---> Running in 64e90da79b81
total 32
drwxr-xr-x 1 node-red node-red 4096 Aug 10 08:54 .
drwxr-xr-x 1 root root 4096 Aug 10 08:54 ..
-rw-r--r-- 1 root root 8567 Aug 10 07:37 flows.json
-rw-r--r-- 1 root root 10546 Aug 10 07:49 settings.js

When I start my container, it simply overrides the flow.json file:

docker run -d -p 1881:1880 --name mynodered --device=/dev/serial0 -v ~/.node-red-docker:/data --user=root --restart=always -e NODE_OPTIONS="--max_old_space_size=128" braghettos/node-red-docker:0.17.5-rpi

Welcome to Node-RED

10 Aug 08:57:48 - [info] Node-RED version: v0.17.5
10 Aug 08:57:48 - [info] Node.js version: v6.11.0
10 Aug 08:57:48 - [info] Linux 4.9.35-v7+ arm LE
10 Aug 08:57:49 - [info] Loading palette nodes
10 Aug 08:57:58 - [info] Settings file : /data/settings.js
10 Aug 08:57:58 - [info] User directory : /data
10 Aug 08:57:58 - [info] Flows file : /data/flows.json
10 Aug 08:57:58 - [info] Creating new flow file
10 Aug 08:57:58 - [info] Server now running at http://127.0.0.1:1880/
10 Aug 08:57:58 - [info] Starting flows
10 Aug 08:57:58 - [info] Started flows

There is no /data/flows.json file created indeed.

If I try to restart the container with the -e FLOWS option, the result is the same:

docker run -d -p 1881:1880 --name mynodered -e FLOWS=/home/pi/docker_aquaponics/braghettos/config/flows.json --device=/dev/serial0 -v ~/.node-red-docker:/data --user=root --restart=always -e NODE_OPTIONS="--max_old_space_size=128" braghettos/node-red-docker:0.17.5-rpi

Welcome to Node-RED

10 Aug 09:02:58 - [info] Node-RED version: v0.17.5
10 Aug 09:02:58 - [info] Node.js version: v6.11.0
10 Aug 09:02:58 - [info] Linux 4.9.35-v7+ arm LE
10 Aug 09:02:59 - [info] Loading palette nodes
10 Aug 09:03:08 - [info] Settings file : /data/settings.js
10 Aug 09:03:08 - [info] User directory : /data
10 Aug 09:03:08 - [info] Flows file : /home/pi/docker_aquaponics/braghettos/config/flows.json
10 Aug 09:03:08 - [info] Creating new flow file
10 Aug 09:03:08 - [info] Server now running at http://127.0.0.1:1880/
10 Aug 09:03:08 - [info] Starting flows
10 Aug 09:03:08 - [info] Started flows

Why Node-RED is creating a news flows file?

from node-red-docker.

jthomas avatar jthomas commented on July 28, 2024

Can you try out this example? If I run the commands below, it builds a new image with a flows.json file.

FROM nodered/node-red-docker:0.17.5-rpi

COPY flows.json /data/
RUN ls -la /data/

Create a new flows.json in the local directory you are building the image from.

[{"id":"b07926e1.1ce808","type":"tab","label":"Flow 1"},{"id":"5cab5e32.ac7f9","type":"inject","z":"b07926e1.1ce808","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":159.5,"y":69,"wires":[["1609cea3.628401"]]},{"id":"1609cea3.628401","type":"debug","z":"b07926e1.1ce808","name":"","active":true,"console":"false","complete":"false","x":615.5,"y":105,"wires":[]}]
 docker build -t nr-flows .
Sending build context to Docker daemon  3.072kB
Step 1/3 : FROM nodered/node-red-docker:0.17.5-rpi
 ---> e17eae2ab9e2
Step 2/3 : COPY flows.json /data/
 ---> 94a1ca91868a
Step 3/3 : RUN ls -la /data/
 ---> Running in d7f63fb6764a
total 12
drwxr-xr-x  2 node-red node-red 4096 Aug 10 10:17 .
drwxr-xr-x 61 root     root     4096 Aug 10 10:17 ..
-rw-r--r--  1 root     root      410 Aug 10 10:09 flows.json
 ---> 31026b07b218
Removing intermediate container d7f63fb6764a
Successfully built 31026b07b218

Running this container locally, I can see the sample flow (inject & debug) from the included flows.json. The logs indicate it's not creating the file.

> [email protected] start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"

10 Aug 10:17:46 - [info]

Welcome to Node-RED
===================

10 Aug 10:17:46 - [info] Node-RED version: v0.17.5
10 Aug 10:17:46 - [info] Node.js  version: v6.11.0
10 Aug 10:17:46 - [info] Linux 4.9.38-moby arm LE
10 Aug 10:17:49 - [info] Loading palette nodes
10 Aug 10:17:57 - [warn] ------------------------------------------------------
10 Aug 10:17:57 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
10 Aug 10:17:57 - [warn] ------------------------------------------------------
10 Aug 10:17:57 - [info] Settings file  : /data/settings.js
10 Aug 10:17:57 - [info] User directory : /data
10 Aug 10:17:57 - [info] Flows file     : /data/flows.json
10 Aug 10:17:58 - [info] Server now running at http://127.0.0.1:1880/
10 Aug 10:17:58 - [info] Starting flows
10 Aug 10:17:58 - [info] Started flows

from node-red-docker.

braghettos avatar braghettos commented on July 28, 2024

I just did it but my result is different.

Sending build context to Docker daemon 58.88kB
Step 1/3 : FROM nodered/node-red-docker:0.17.5-rpi
---> e17eae2ab9e2
Step 2/3 : COPY flows.json /data/
---> 04c1fbc79ef1
Removing intermediate container 1bc093ef53bf
Step 3/3 : RUN ls -la /data/
---> Running in b1ce72807838
total 12
drwxr-xr-x 1 node-red node-red 4096 Aug 10 10:53 .
drwxr-xr-x 1 root root 4096 Aug 10 10:53 ..
-rw-r--r-- 1 root root 411 Aug 10 10:53 flows.json
---> 002d75806c57
Removing intermediate container b1ce72807838
Successfully built 002d75806c57
Successfully tagged braghettos/node-red-docker:0.17.5-rpi

Maybe the difference is how we run the container?

docker run -d -p 1881:1880 --name mynodered --device=/dev/serial0 -v ~/.node-red-docker:/data --user=root --restart=always -e NODE_OPTIONS="--max_old_space_size=128" braghettos/node-red-docker:0.17.5-rpi

npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]

[email protected] start /usr/src/node-red
node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"

10 Aug 10:54:42 - [info]

Welcome to Node-RED

10 Aug 10:54:42 - [info] Node-RED version: v0.17.5
10 Aug 10:54:42 - [info] Node.js version: v6.11.0
10 Aug 10:54:42 - [info] Linux 4.9.35-v7+ arm LE
10 Aug 10:54:43 - [info] Loading palette nodes
10 Aug 10:54:46 - [info] Settings file : /data/settings.js
10 Aug 10:54:46 - [info] User directory : /data
10 Aug 10:54:46 - [info] Flows file : /data/flows.json
10 Aug 10:54:46 - [info] Creating new flow file
10 Aug 10:54:46 - [info] Server now running at http://127.0.0.1:1880/
10 Aug 10:54:47 - [info] Starting flows
10 Aug 10:54:47 - [info] Started flows

I need to use --user=root in order to use the serial port

from node-red-docker.

jthomas avatar jthomas commented on July 28, 2024

This line is the issue:

-v ~/.node-red-docker:/data

Mounting this directory into /data overwrites the existing folder which contains the flows.json. I've tested this with an empty local directory and see the same issue. If I remove the volume mount, it works.

Removing this flag will allow the container to use the built-in files.

from node-red-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.