Connection to server at "db" (host), post 5432 failed: FATAL: database "<db_name>" does not exist

version: '3.7'

services:
  db:
    image: postgres:13
    restart: always
    environment:
      POSTGRES_DB: <db_name>
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports:
      - "5432:5432"
    networks:
      - internal_network
    volumes:
      - postgres_data:/var/lib/postgresql/data

  backend:
    image: backend-image
    volumes:
      - static_volume:/src/backend/static
      - media_volume:/src/backend/media
    env_file:
      - ./backend/.env
    build: ./backend
    ports:
      - "8000:8000"
    depends_on:
      - redis
      - db
    networks:
      - internal_network

volumes:
  static_volume:
  media_volume:
  postgres_data:

networks:
  internal_network:
    driver: bridge

I have a problem after some time I delete the database about 3 days after I do docker-compose up -d The docker-compose.yml itself is written correctly but I don't understand why the database is deleted. In the logs I looked at

logs:2024-09-11 08:43:23.829 UTC [11436] 
FATAL:  password authentication failed for user "postgres"2024-09-11 08:43:23.829 UTC [11436] 
DETAIL:  Password does not match for user "postgres". Connection matched pg_hba.conf line 99: "host all all all md5"2024-09-11 08:44:24.551 UTC [11437] 
FATAL:  canceling authentication due to timeout2024-09-11 08:55:20.062 UTC [11486] 
FATAL:  database "<db_name>" does not exist
Back to Top