Docker撰写v3 - “卷的不支持的配置选项:”

时间:2018-01-17 22:34:33

标签: docker docker-compose yaml

我有一个yml文件,其配置可以运行两个容器。这是文件:

web:
  build: ./web
  ports:
    - "8000:8000"
  restart: always
  volumes:
    - website:/www/

  nginx:
    build: ./nginx
    ports:
     - "80:80"
    restart: always
    links:
     - web
    volumes:
     - website:/www/

volumes:
  website:

当我运行此操作时,我总是会收到以下错误:

The Compose file '.\docker-compose.yml' is invalid because:
Unsupported config option for volumes: 'website'

我用谷歌搜索了这个,我觉得这很好,就像现在一样。这有什么问题?

1 个答案:

答案 0 :(得分:0)

我认为你应该在docker-compose文件中添加versionservices

version: '3'
services:
  web:
   build: ./web
   ports:
     - "8000:8000"
   restart: always
   volumes:
    - website:/www/

  nginx:
    build: ./nginx
    ports:
     - "80:80"
    restart: always
    links:
     - web
    volumes:
     - website:/www/

volumes:
  website:

参考: