# Node red and docker and mount

**URL:** <https://discourse.nodered.org/t/node-red-and-docker-and-mount/44227>\
**Category:** General\
**Created:** [15 April 2021 11:44 UTC](https://discourse.nodered.org/t/node-red-and-docker-and-mount/44227 "2021-04-15T11:44:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pvklink](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@pvklink](https://discourse.nodered.org/u/pvklink)\
**Post date:** [15 April 2021 11:44 UTC](https://discourse.nodered.org/t/node-red-and-docker-and-mount/44227/1 "2021-04-15T11:44:54Z")

</div>

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

```auto
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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Kib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kib/32/27493_2.png) [@Kib](https://discourse.nodered.org/u/Kib)\
**Post date:** [15 April 2021 16:13 UTC](https://discourse.nodered.org/t/node-red-and-docker-and-mount/44227/2 "2021-04-15T16:13:34Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![pvklink](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@pvklink](https://discourse.nodered.org/u/pvklink)\
**Post date:** [15 April 2021 17:22 UTC](https://discourse.nodered.org/t/node-red-and-docker-and-mount/44227/3 "2021-04-15T17:22:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pvklink](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@pvklink](https://discourse.nodered.org/u/pvklink)\
**Post date:** [18 April 2021 20:38 UTC](https://discourse.nodered.org/t/node-red-and-docker-and-mount/44227/4 "2021-04-18T20:38:14Z")

</div>

Solved it, wil publish the solution soon

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 June 2021 20:38 UTC](https://discourse.nodered.org/t/node-red-and-docker-and-mount/44227/5 "2021-06-17T20:38:54Z")

</div>

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