'How do I create an external volume using docker compose?
Basing on this Node-RED tutorial, I'm trying to mount an external volume with the Node-RED files outside the docker machine. I'm using the following docker-compose file:
version: "3.7"
services:
  node-red:
    image: nodered/node-red:latest
    environment:
      - TZ=Europe/Amsterdam
    ports:
      - "2000:1880"
    networks:
      - node-red-net
    volumes:
      - node-red-data:/home/user/node-red1
volumes:
  node-red-data:
networks:
  node-red-net:
However, even though this file works fine when I run docker-compose up, the volume exists only inside the docker machine. I've tried adding the line external: true in volumes but I get the following error:
ERROR: In file './docker-compose.yml', volume 'external' must be a mapping not a boolean. 
What am I missing? How do I mount an external volume using docker-compose files?
Solution 1:[1]
I ended up finding a related question with this answer. There are multiple answers that didn't work for me there (also there's no accepted answer). The syntax that worked was:
  node-red-data:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /path/external/folder
So the final dockerfile that works after running docker-compose up is:
version: "3.7"
services:
  node-red:
    image: nodered/node-red:latest
    environment:
      - TZ=Europe/Amsterdam
    ports:
      - "2000:1880"
    networks:
      - node-red-net
    volumes:
      - node-red-data:/data
    container_name: node-red
volumes:
  node-red-data:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: "/home/user/node-red1"
networks:
  node-red-net:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | raylight | 
