I have a springboot application that conncects to a postgres database that i want to be dockerised. The below is my docker-compose.yml file.
version: "3.1"
services:
db-minot-postgres:
image: "postgres:latest"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: minot
ports:
- "5432:5432"
volumes:
- ./data:/var/lib/postgresql/data
networks:
- minot-network
app:
build:
context: .
dockerfile: Dockerfile
image: minotaur:1.0
depends_on:
- db-minot-postgres
environment:
SPRING_DATASOURCE_DB: minotaur
SPRING_DATASOURCE_URL: jdbc:postgresql://db-minotaur-postgres:5432/minot
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: postgres
SPRING_DATASOURCE_DRIVER-CLASS-NAME: org.postgresql.Driver
ports:
- "8080:8080"
networks:
- minot-network
networks:
minot-network:
I first pulled the postgres image and then i deploy the application below so that it connects to the postgres image but i get the error
minot-db-minot-postgres-1 | 2023-03-27 05:55:09.829 UTC [35] FATAL: database "minot" does not exist
I dont know why it cant detect the databse as i thought when declaring the enviroment variables since the database minotaur is declared it shouldnt be a problem. Help please. How do i stop this error.