skip to Main Content
services:
    postgres:
        container_name: 'lh-postgres'
        image: 'postgres:13'
        environment:
            POSTGRES_PASSWORD: root
    redis:
        container_name: 'lh-redis'
        image: 'redis:6'
    nginx:
        container_name: 'lh-nginx'
        build: ./nginx
        depends_on:
            - php-fpm
        volumes:
            - ./src/lh-app:/var/www/html/app
            - ./src/lh-api:/var/www/html/api
        ports:
            - "80:80"
            - "443:443"
    php-fpm:
        container_name: 'lh-php'
        image: docker.io/bitnami/php-fpm:8.0
        user: '1000:1000'
        build:
            context: ./php-fpm
            args:
                - PHP_ENV= development
        depends_on:
            - postgres
            - redis
        volumes:
            - ./src/lh-app:/var/www/html/app
            - ./src/lh-api:/var/www/html/api

ERROR: The Compose file ‘./docker-compose.yml’ is invalid because:

Unsupported config option for services: ‘postgres’

getting this error

3

Answers


  1. You should include your docker and docker-compose version in the querstion to help us answer you.

    It would also be wise to define the version: 'x' element at the top of your compose file.

    You may be suffering from an old version of the cli, akin to this question:

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

    Login or Signup to reply.
  2. I think you are missing some ENV vars.

    This is our docker-compose.yml for Postgres

    version: '3.9'
    
    services:
    
      db:
        image: postgres:latest
        restart: "no"
        container_name: db
        volumes:
          - ./database:/var/lib/postgresql/data
        ports:
          - "8002:5432"
        environment:
          POSTGRES_PASSWORD: verySecurePassword34058
          POSTGRES_USER: root
          POSTGRES_DB: myDatabase
    
    networks:
      default:
        external: true
        name: our-network
    

    Other parts of the application, (like Redis, the NodeJS App, etc) are in other docker-compose.yml files, But since they share the same network, they talk to each other.

    Login or Signup to reply.
  3. You have not mentioned version in docker-composer.yml

    version: '2'
    

    services:
    postgres:
    container_name: ‘lh-postgres’
    image: ‘postgres:13’
    environment:
    POSTGRES_PASSWORD: root
    redis:
    container_name: ‘lh-redis’
    image: ‘redis:6’

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search