Skip to content

Node RED

Graham Garner edited this page Nov 2, 2019 · 11 revisions

Sharing files between Node-RED and the host

Containers run in a sandboxed environment they can't see the host (the Pi itself) file system. This presents a problem if you want to read a file directly to the host from inside the container. Fortunately there is a method, the containers have been set up with volume mapping. The volume maps a specific directory or file from the host file system into the container. Therefore if you write to that directory both the host and the container can see the files.

Consider the following:

The docker-compose.yml file shows the following for Node-RED

    volumes:
      - ./volumes/nodered/data:/data

If inside Node-RED you were to write to the /data folder then the host would see it in ~/IOTstack/volumes/nodered/data (the ./volumes above implies relative to the docker-compose.yml file)

image

The flow writes the file /data/test.txt and it is visible in the host as ~/IOTstack/volumes/nodered/data/test.txt

I would be a good idea to use a sub directory in /data to separate out the files

Clone this wiki locally