2

I need to create a volume with "docker volume" with a personal Mountpoint (mountpoint="/my/path/ not /var/lib/docker...) but i can't use plugin like local-persist

docker volume create -d local-persist -o mountpoint=/data/images --name=images

i need something like this but without plugin, maybe it can be done with --opt= and somethig after that, but i'm new at docker and linux. I hope someone can help me, just pay attention: i need "docker volume create" not something that let me use personal path in docker-compose.yml or something like this.

Edit

my docker compose is something like

version: '3.1'

services:

  grafana:
    image: grafana/grafana:5.3.4
    ports:
      - 3000:3000
    volumes:
      - grafanasql:/var/lib/grafana
      - grafanaconf:/etc/grafana
  ...
  ...
  volumes:
    grafanasql:
      external: true
    grafanaconf:
      external: true

If i let docker create volumes all its ok, but when i try to use external volume, with your docker volume create it doesnt work.

Mirco
  • 212
  • 3
  • 12

1 Answers1

6

The syntax is

docker volume create -d local -o o=bind -o device=/your/path

Or in docker-compose

volumes:
  mydata:
    driver: local
    driver_opts:
      o: bind
      device: /your/path
Siyu
  • 11,187
  • 4
  • 43
  • 55
  • 1
    i try it but when i inspect the volume "pippo" the mountpoint is always the same /var/lib/docker/volumes....., and when i try to use this volume it doesnt work – Mirco Jan 21 '19 at 15:05
  • Yes `Mountpoint` is still that, but `docker run -v volume_just_created:/test ubuntu ls /test` will return the content of `/your/path` – Siyu Jan 21 '19 at 15:09
  • i add my docker-compose too explain better my throuble. – Mirco Jan 21 '19 at 15:24
  • I also had to add `type: none` to `driver_opts` (docker-compose v3.2). – janw Oct 23 '20 at 19:18