Node red and docker and mount

I am busy with dockering my domotica environment.

I use the following compose-file and dockerfile to docker nodered and some dependencies
Questions i have:

  1. i like to mount a usb drive to node-red to store camera-data on it during a nodered flow
    How can i achive that ?

  2. i tried to test these commands within the nodered-container with
    sudo docker exec -i -t nodered /bin/sh
    But when i put commands in this container like: dir i get : command not found!
    How can i make these container a little bit smarter...

compose file

version: '3.6'
services:
  mysql:
    container_name: mysql
    image: biarms/mysql
    restart: always
    volumes:
    - ./volumes/mysql/data:/var/lib/mysql
    ports:
    - '6603:3306'
    environment:
      MYSQL_ROOT_PASSWORD: "xxxxxx"
  mosquitto:
    container_name: mosquitto
    image: eclipse-mosquitto
    restart: unless-stopped
    user: "1000"
    ports:
    - "1883:1883"
    volumes:
    - ./volumes/mosquitto/data:/mosquitto/data
    - ./volumes/mosquitto/log:/mosquitto/log
    - ./volumes/mosquitto/pwfile:/mosquitto/pwfile
    - ./volumes/mosquitto/config:/mosquitto/config:ro
    network_mode: bridge
  phpmyadmin:
    container_name: phpmyadmin
    image: phpmyadmin:latest
    restart: always
    depends_on:
      - mysql
    ports:
      - '8080:80'
    environment:
      PMA_HOST: mysql
  nodered:
    container_name: nodered
    build: ./services/nodered/.
    restart: unless-stopped
    depends_on:
      - mysql
      - mosquitto
    user: "0"
    privileged: true
    environment:
      - TZ=Etc/UTC
    ports:
      - "1880:1880"
    #  - "443:443"
    volumes:
      - "./volumes/nodered/data:/data"
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket"
    devices:
      - "/dev/gpiomem:/dev/gpiomem"
      - "/dev/ttyAMA0:/dev/ttyAMA0"
      - "/dev/vcio:/dev/vcio"
    networks:
      - iotstack_nw
    logging:
      options:
        max-size: 5m
        max-file: "3"
networks:
  iotstack_nw:
    name: IOTstack_Net
    # external: true
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 10.77.60.0/24

dockerfile

FROM nodered/node-red:latest
USER root

# how can i mount a usb device so that flows can store data on this device 

RUN apk update && apk add --no-cache eudev-dev
USER node-red
RUN cd /usr/src/node-red && npm install --save node-red-configurable-ping node-red-node-mysql node-red-dashboard node-red-node-random node-red-node-email node-red-contrib-cast node-red-contrib-castv2 node-red-contrib-fs-ops node-red-contrib-ip node-red-contrib-moment node-red-contrib-nora node-red-contrib-queue-gate node-red-contrib-repeat node-red-contrib-sonos-plus node-red-dashboard node-red-node-base64 node-red-node-email node-red-node-pushover node-red-node-ui-list node-red-node-ui-table
or paste code here

From what i understand, NodeRED is running as a service seeing from your docker-compose file. So you want to use a directory inside node-red? Do you mean with node?

The paths as far as the container go are isolated. so you can store to a directory like /usr/data/some_folder as long as you know what the directory is.
The next step would be to mount this directory as a volume to the host system. you would have to write this inside your docker-compose file inside the nodered service.

volumes: 
        - /Drive_location : /usr/data/some_folder 

The right part amounts to the directory inside the container that node will use, and the left part is the drive you want to link.

I like to:

  1. store data from a flow to a folder x
  2. x is in fact an usb drive (OR a folder on the usb drive)
  3. x must be available outside node-red

Solved it, wil publish the solution soon

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