Create volume with docker volume with a custom Mountpoint

独自空忆成欢 提交于 2020-01-03 02:11:12

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/54292283/create-volume-with-docker-volume-with-a-custom-mountpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!