PostgreSQL docker-compose: FATAL: database does not exist

Viewed 102

I'm getting the following error with postgreSQL with docker-compose:

postgres_1 | 2021-11-26 18:02:47.131 UTC [138] FATAL: database "preferences" does not exist

Just run docker-compose up to reproduce the issue.

version: '2.4'

services:
  postgres:
    image: postgis/postgis:12-3.0
    ports:
      - '5432:5432'
    environment:
      - POSTGRES_DB=preferences
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
    volumes:
      - ./docker/postgres:/docker-entrypoint-initdb.d/
      - dev-postgres-data:/var/lib/postgresql/data

    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB']
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - dev
  
networks:
  dev:
    external: true

volumes:
  dev-postgres-data:
    external: true

0 Answers
Related