Docker error: service must be a mapping, not a None Type.

Synopsis

When I was building the environment with Docker, I encountered such a build error.

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

Post a memorandum on how to deal with this error and why it occurred.

Reason for error

Because the indentation is inappropriate. Probably some half-width space is missing.

solution

Suppose you get an error in docker-compose.yml like this. Example

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"

As a solution, add two half-width spaces under react-navigation and change it like this.

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"

Afterword

Probably an error that people who have just learned Docker will encounter. I hope this article will be useful for those people and myself.

Recommended Posts

Docker error: service must be a mapping, not a None Type.
Rails must be exist error (@save is not executed)
To not be a static uncle
In file'./docker-compose.yml', the service name True must be a quoted string, i.e.'True'.
lombok.Data Boolean type value could not be taken and was at a loss