3
1

More than 3 years have passed since last update.

エラー「ERROR: The Compose file './docker-compose.yml' is invalid because:」の対処法

Posted at
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の文法は-(ハイフン)の後ろには必ず半角スペースが必要です。
うっかり見落としていました。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1