docker 中的无效类型 - 撰写卷

Invalid type in docker-compose volume

我尝试在 docker-compose 中设置一个 bind 卷,但出现以下错误:

docker-compose up
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.web.volumes contains an invalid type, it should be a string

我的 docker-compose 文件:

version: '3'
services:
  web:
    #build: .
    image: fnndsc/fnndsc.babymri.org
    ports:
      - "8060:8080"
    volumes:
      - type: "bind"
        source: "."
        target: "/src/website"
    labels:
      name: "FNNDSC Web App"
      role: "FNNDSC Web App development server"

版本:

Docker version 17.03.1-ce, build c6d412e

docker-compose version 1.12.0, build b31ff33

我尝试了很多不同的组合,但似乎没有任何效果...

谢谢!

试试这个:

version: '3'
services:
  web:
    #build: .
    image: fnndsc/fnndsc.babymri.org
    ports:
      - "8060:8080"
    volumes:
      - .:/src/website
    labels:
      name: "FNNDSC Web App"
      role: "FNNDSC Web App development server"

扩展符号需要 3.2 版:

version: '3.2'
services:
  web:
    #build: .
    image: fnndsc/fnndsc.babymri.org
    ports:
      - "8060:8080"
    volumes:
      - type: bind
        source: .
        target: /src/website
    labels:
      name: "FNNDSC Web App"
      role: "FNNDSC Web App development server"

参考:https://github.com/docker/compose/issues/4763#issuecomment-297509279