这是我的docker-compose.yml
version: "3"
services:
drupal:
image: drupal
ports:
- "8080:80"
volumes:
- drupal-modules:/var/www/html/modules
- drupal-profiles:/var/www/html/profiles
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=mypasswd
volumes:
drupal-modules:
drupal-profiles:
drupal-sites:
drupal-themes:当我跑的时候
$ docker-compose up我得到:
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
Unsupported config option for services.drupal: 'postgres'有什么问题吗?
发布于 2021-05-14 17:49:43
docker-compose.yml中的缩进是不正确的,因为.yml文件是缩进敏感的.
您有三个错误:
ports是一个key:value数据,所以在下一个line.volumes中应该缩进-是一个key:value数据,所以-应该缩进下一个line.postgres服务的缩进应该在与drupal.相同的级别上
因此,您的文件应该如下所示:
version: "3"
services:
drupal:
image: drupal
ports:
- "8080:80"
volumes:
- drupal-modules:/var/www/html/modules
- drupal-profiles:/var/www/html/profiles
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=mypasswd
volumes:
drupal-modules:
drupal-profiles:
drupal-sites:
drupal-themes:发布于 2021-05-14 17:05:11
解出
每次你看到
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
Unsupported config option for问题很可能在于错误的缩进,因为事实就是如此。
首先,postgres和drupal都是容器(所以是services),因此它们必须具有相同的缩进级别,即比services少一个缩进级别。
在整个postgres结构/树中减少一个缩进级别。
其次,以-开头的每个元素必须比它所属的元素多一个缩进级别。
因此,在ports和volumes元素中再添加一个缩进级别。
下面是修正后的docker-compose.yml:
version: "3"
services:
drupal:
image: drupal
ports:
- "8080:80"
volumes:
- drupal-modules:/var/www/html/modules
- drupal-profiles:/var/www/html/profiles
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=mypasswd
volumes:
drupal-modules:
drupal-profiles:
drupal-sites:
drupal-themes:https://stackoverflow.com/questions/67538259
复制相似问题