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

Hi, I am trying to use the example provided in the site

Step 3: Define services Define a set of services using docker-compose.yml:

Create a file called docker-compose.yml in your project directory and add the following:

version: '2'
    build: .
     - "5000:5000"
     - .:/code
     - redis
    image: redis

and when I run the command docker-compose up i got the below error

ERROR: yaml.scanner.ScannerError: while scanning for the next token found character ‘\t’ that cannot start any token in “./docker-compose.yml”, line 18, column 1 so i removed all spaces and modified it as below

Defines two web services, web and redis

version: ‘2’ services: web: build: . #Build from the dockerfile from current dir ports:

  • “5000:5000” #Forward the exposed port 5000 on the container to port 5000 on the host machine volumes:
  • .:/code #Mounts the project directory on the host to /code inside the container directory allowing you to modify the code without having to rebuild the image depends_on:
  • redis redis: image: redis #Links the webservice to the redis service

on trying it again i am getting an error now as

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

Can I get some help what is wrong here… I am using MAC.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This question was answered by @VVP:

i got the right file

version: ‘2’ services: web: build: . ports:

  • “5000:5000” volumes:
  • .:/code
  • logvolume01:/var/log links:
  • redis redis: image: redis volumes: logvolume01: {}

This is working … can refer the following link :)

View the original comment