ERROR: The Compose file './docker-compose.yml' is invalid because:
services.php.volumes contains an invalid type, it should be an array
docker-compose up
した時に上記のようなエラーが出た場合の対処法です。
原因はYaml文法エラー
エラー内容のservices.php.volumes
の部分の文法が不正ということです。
Before : 不正な文法
(不正文法)docker-compose.yml
version: '3'
services:
nginx:
image: nginx:latest
ports:
- 8080:80
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- ./wwww/html:/var/www/html
depends_on:
- php
php:
build: ./php
volumes:
-./www/html:/var/www/html
After : 正しい文法
(正しい文法)docker-compose.yml
version: '3'
services:
nginx:
image: nginx:latest
ports:
- 8080:80
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- ./wwww/html:/var/www/html
depends_on:
- php
php:
build: ./php
volumes:
- ./www/html:/var/www/html
具体的には以下の部分です。
Before : 不正な文法
-./www/html:/var/www/html
After : 正しい文法
- ./www/html:/var/www/html
Yamlの文法は-(ハイフン)
の後ろには必ず半角スペースが必要です。
うっかり見落としていました。