docker-compose : Unsupported config option for services service: 'web'

DockerDocker Compose

Docker Problem Overview


I am going through the Getting Started with Docker Compose page.

In Step 3, I made a docker-compose.yml file as described:

version: '2'
services:
    web:
        build: .
        ports: 
            - "5000:5000"
        volumes: 
            - .:/code
        depends_on:
            - redis
    redis:
        image: redis

But when I run:

$ docker-compose up

I get following error:

> Unsupported config option for services service: 'web'

What am I doing wrong? I was not able to figure out what is going on.

Docker Solutions


Solution 1 - Docker

Support for the version 2 compose file format was introduced in docker-compose version 1.6, released around February of this year.

You're using 1.3.3, from July 2015.

You need to upgrade to a more recent version to use the version 2 format configuration files.

Solution 2 - Docker

Since this is the first result on Googling "docker-compose Unsupported config option for services", I would like to add that the most common reason as of 2020 is missing of version: "3".

Just add version: "3" to the start of your docker-compose.yml.

From the docs:

> There are currently three versions of the Compose file format: > 1. Version 1, the legacy format. This is specified by omitting a version key at the root of the YAML. > 2. Version 2.x. This is specified with a version: '2' or version: '2.1', etc., entry at the root of the YAML. > 3. Version 3.x, the latest and recommended version, designed to be cross-compatible between Compose and the Docker Engine’s swarm mode. This is specified with a version: '3' or version: '3.1', etc., entry at the root of the YAML.

Solution 3 - Docker

In my case i had used a wrong indentation. Recheck indentation of your docker-compose file to ensure it is correct

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDarcliGhtView Question on Stackoverflow
Solution 1 - DockerlarsksView Answer on Stackoverflow
Solution 2 - DockerospiderView Answer on Stackoverflow
Solution 3 - DockerMuteshiView Answer on Stackoverflow