装载卷docker compose

时间:2018-11-22 09:58:33

标签: docker docker-compose dockerfile mount-point

我使用以下命令从我的一张图片创建自己的docker容器

docker run -d --name orchestrator --restart unless-stopped -p 80:80 -p 1099:1099 -p 8101:8101 -p 44444:44444 -p 8181:8181 -p 5005:5005 -p 8443:8443 -p 1883:1883 -p 8161:8161 -p 5672:5672 -p 42699:42699 -p 61613:61613 -p 61614:61614 -p 61616:61616 
--mount source=etc,target=/opt/karaf/etc,volume-driver=local,volume-opt=type=none,volume-opt=o=bind,volume-opt=device=’SHARE_DIR/etc/'
--mount source=deploy,target=/opt/karaf/deploy,volume-driver=local,volume-opt=type=none,volume-opt=o=bind,volume-opt=device=’SHARE_DIR/deploy/'
--mount source=log,target=/opt/karaf/data/log,volume-driver=local,volume-opt=type=none,volume-opt=o=bind,volume-opt=device=’SHARE_DIR/log/'
--mount source=configuration,target=/opt/karaf/configuration,volume-driver=local,volume-opt=type=none,volume-opt=o=bind,volume-opt=device='SHARE_DIR/configuration/'
image-name

我需要对docker compose做同样的事情,但是特别是在创建卷时遇到了问题。

这是我的docker-compose.yml

版本:“ 3.2”

services: orchestrator:
    build: .
    container_name: orchestrator
    restart: unless-stopped
    ports:
      - "80:80"
      - "1099:1099"
      - "8101:8101"
      - "44444:44444"
      - "8181:8181"
      - "5005:5005"
      - "8443:8443"
    volumes:
      - source=configuration target=/opt/karaf/configuration
    volume-driver=local
    volume-opt=type=none
    volume-opt=o=bind
    volume-opt=device='local-path/orch-orch-49-compose/configuration/'

1 个答案:

答案 0 :(得分:0)

长语法文档为here。卷部分应类似于:

volumes:
  - type: volume
    source: my-vol
    target: /opt/karaf/configuration

volumes:
  my-vol:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: 'local-path/orch-orch-49-compose/configuration/'

有关driver_opts,请参见here