Haris Mahmood
Haris Mahmood

Reputation: 21

Invalid docker.compose.yaml file

I am trying to get a couple of containers up and running, however I am running into some issues. I run this command:

docker-compose up -d --build itvdflab

and get this error

The Compose file './docker-compose.yaml' is invalid because: Unsupported config option for services: 'itvdelab' Unsupported config option for networks: 'itvdelabnw'

Here is the yaml file.

 services:
  itvdelab:
    image: itversity/itvdelab
    hostname: itvdelab
    ports:
      - "8888:8888"
    volumes:
      - "./itversity-material:/home/itversity/itversity-material"
      - "./data:/data"
    environment:
      SHELL: /bin/bash
    networks:
      - itvdelabnw
    depends_on:
      - "cluster_util_db"
  cluster_util_db:
    image: postgres:13
    ports:
      - "6432:5432"
    volumes:
      - ./cluster_util_db_scripts:/docker-entrypoint-initdb.d
    networks:
      - itvdelabnw
    environment:
      POSTGRES_PASSWORD: itversity
  itvdflab:
    build:
      context: .
      dockerfile: images/pythonsql/Dockerfile
    hostname: itvdflab
    ports:
      - "8888:8888"
    volumes:
      - "./itversity-material:/home/itversity/itversity-material"
      - "./data:/data"
    environment:
      SHELL: /bin/bash
    networks:
      - itvdelabnw
    depends_on:
      - "pg.itversity.com"
  pg.itversity.com:
    image: postgres:13
    ports:
      - "5432:5432"
    networks:
      - itvdelabnw
    environment:
      POSTGRES_PASSWORD: itversity
networks:
  itvdelabnw:
    name: itvdelabnw

What changes do I need to make to get this working?

Upvotes: 0

Views: 1472

Answers (2)

lowstrife
lowstrife

Reputation: 1

for me work try different version. In my case work

version: '2.2'

Upvotes: 0

David Maze
David Maze

Reputation: 158714

Your docker-compose.yml file is missing a version: line. Until very recently, this caused Docker Compose to interpret this as the original "version 1" Compose format, which doesn't have a top-level services: key and doesn't support Docker networks. The much newer Compose Specification claims that a version: key is optional, but in practice if you can't be guaranteed to use a very new version of Compose (built as a plugin to the docker binary) it's required. The most recent Compose file versions supported by the standalone Python docker-compose tool are 3.8 and 2.4 (you need the 2.x version for some resource-related constraints in non-Swarm installations).

# Add at the very beginning
version: '3.8'

Upvotes: 1

Related Questions