ERROR The Compose file Docker-Compose is invalid because

Asked

Viewed 29 times

0

I’m getting this error message;

inserir a descrição da imagem aqui

This message appears when running Docker-Compose.yml, take a look at how it looks like!

version: "3.5"
services:
  kwan:
    image: postgres
    container_name: postgres-kwan
    environment:
      - POSTGRES_PASSWORD=root
      - POSTGRES_USER=postgres
      - POSTGRES_DB=POSTGRESQL
    ports:
      - "15432:5432"
    volumes:
      - pgdata-teste:/var/lib/postgresql/data

    healthcheck:
    test: ["CMD-SHELL", "pg_isready -U postgres"]
    interval: 5s
    timeout: 3s
    retries: 5
    networks:
      - postgres-compose-network


networks: 
  postgres-compose-network:
    driver: bridge

I don’t know how to fix!

1 answer

0

YAML files have indentation-based notation. This means that one should take the appropriate step back when defining parameters of the same configuration (by convention, two blanks are used as indentation).

Your mistake was in the structure services.kwan.healthcheck. There you need to correct the indentation according to the documentation, giving the recoil to the keys test, interval, timeout and retries, that are part of the configuration healthcheck.

Your file then should be like this:

version: "3.5"
services:
  kwan:
    image: postgres
    container_name: postgres-kwan
    environment:
      - POSTGRES_PASSWORD=root
      - POSTGRES_USER=postgres
      - POSTGRES_DB=POSTGRESQL
    ports:
      - "15432:5432"
    volumes:
      - pgdata-teste:/var/lib/postgresql/data

    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 3s
      retries: 5
    networks:
      - postgres-compose-network


networks: 
  postgres-compose-network:
    driver: bridge

Browser other questions tagged

You are not signed in. Login or sign up in order to post.