如何在docker-compose中使用docker swarm配置卷路径

时间:2019-11-25 17:34:36

标签: docker-compose docker-swarm

我将docker compose配置为创建默认卷,但是现在我需要自定义卷的本地路径,我尝试通过绑定绑定设备并通过设备选项指定路径来执行一些driver_opts,但是在这种情况下,容器中出现了群体抛出错误“安装失败。 ..目录不存在”。那么如何配置卷的本地路径?

这是我的docker compose

version: '3'

services:
    xxx:
       image: image-xxx
       deploy:
           mode: replicated
           replicas: 2
       volumes:
         - xxxvolume:/usr/src/xxx/yyy/

volumes:
  xxxvolume:
    driver: 'local'

音量信息是

[
    {
        "CreatedAt": "2019-11-24T19:05:03+01:00",
        "Driver": "local",
        "Labels": {
            "com.docker.stack.namespace": "XX"
        },
        "Mountpoint": "/var/lib/docker/volumes/xxx/_data",
        "Name": "XX_xxvolume",
        "Options": null,
        "Scope": "local"
    }
]

1 个答案:

答案 0 :(得分:1)

docker-compose.yml

version: '3.7'

services:
  jira:
    image: atlassian/jira-software
    volumes:
      - ./volumes/jira_vol:/var/atlassian/application-data/jira
    ports:
      - 8080:8080

volumes:
  jira_vol:
    external: false

并运行此命令;

docker-compose up -d

最后在同一路径中添加了卷目录!