在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java/ docker-compose.yml如何寫一個容器需要掛載另一個容器的數(shù)據(jù)卷???

docker-compose.yml如何寫一個容器需要掛載另一個容器的數(shù)據(jù)卷?。?/h1>

下面的是官方的寫法

version: "3.2"
services:
  web:
    image: nginx:alpine
    volumes:
      - type: volume
        source: mydata
        target: /data
        volume:
          nocopy: true
      - type: bind
        source: ./static
        target: /opt/app/static

  db:
    image: postgres:latest
    volumes:
      - "/var/run/postgres/postgres.sock:/var/run/postgres/postgres.sock"
      - "dbdata:/var/lib/postgresql/data"

volumes:
  mydata:
  dbdata:

我照著改運行報錯

我的容器有一個是寫在其他地方的,不是同一個文件寫的

回答
編輯回答
心悲涼

表明external: true即可:

version: "3.2"
services:

  db:
    image: postgres:latest
    volumes:
      - "/var/run/postgres/postgres.sock:/var/run/postgres/postgres.sock"
      - "dbdata:/var/lib/postgresql/data"

volumes:
  dbdata:
    external: true
2017年8月28日 20:40