LoginSignup
6
4

More than 3 years have passed since last update.

Docker エラー:service must be a mapping, not a NoneType.

Posted at

あらすじ

Dockerで環境構築を行っていたら、このようなbuildエラーに出会った。

ERROR: In file './docker-compose.yml', service must be a mapping, not a NoneType.

このエラーの対処方と発生理由を備忘録として投稿する。

エラー発生理由

インデントが不適切であるため。おそらくどこかの半角スペースが抜けている。

解決策

このようなdocker-compose.ymlでエラーが起きたとする。
例 

version: "3"
services:
react-navigation:
  build: ./
  volumes:
    - ./react-navigation/:/usr/src/app
  env_file: .env
  command: bash -c "cd example && yarn start"
  ports:
    - "19000:19000"
    - "19001:19001"
    - "19002:19002"

解決方法としては、react-navigation以下に半角スペース2個分を追加で入れ、このように変更する。

version: "3"
services:
  react-navigation:
    build: ./
    volumes:
      - ./react-navigation/:/usr/src/app
    env_file: .env
    command: bash -c "cd example && yarn start"
    ports:
      - "19000:19000"
      - "19001:19001"
      - "19002:19002"

あとがき

おそらくDocker習ったばかりの人は出会うであろうエラー。
そういった方々と自分のためにこの記事が役にたてばいいなと思います。

6
4
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
6
4