Search code examples
dockerdocker-composedocker-machine

Version in "./docker-compose.yml" is unsupported


I have the following docker-compose.yml file

services:
  containerA:
    healthcheck:
      test: "/build/docheck"
      interval: "10s"
    hostname: "containerA"
    container_name: "containerA"
    build:
      dockerfile: "Dockerfile-5.6"
    ports:
    - "8081:8081"
version: "2.1"

When I try the following command: docker-compose up

it fails due to:

ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or "2.0") and place your service definitions under the services key, or omit the version key and place your service definitions at the root of the file to use version 1. For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

I have the following setting:

$> docker-compose --version
docker-compose version 1.8.0, build unknown

$> docker --version
Docker version 17.12.0-ce, build c97c6d6

$> uname -r
4.9.0-4-amd64

$> lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 9.3 (stretch)
Release:    9.3
Codename:   stretch

I need to use version 2.1 because I am using the healthcheck. Any ideas why this is complaining?


Solution

  • Following the link to details about versions, you'll find:

    Version 2.1

    An upgrade of version 2 that introduces new parameters only available with Docker Engine version 1.12.0+. Version 2.1 files are supported by Compose 1.9.0+.

    https://docs.docker.com/compose/compose-file/compose-versioning/#version-21

    You'll need to upgrade your docker-compose install to support the 2.1 file version. https://docs.docker.com/compose/install/