Relative Content

Tag Archive for postgresqlspring-bootdockerdocker-compose

Docker Compose PostgreSQL Data Persistence Not Working as Expected

I’m having trouble with data persistence in my Docker Compose setup for a Spring Boot application that uses PostgreSQL. The data persists only when I stop the PostgreSQL container individually and start it again, but when I bring the entire Docker Compose stack down and then up again, the data is lost.
Here’s my docker-compose.yml file:

Docker Compose: Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused

I want to create a simple spring boot project using the Postgresql database. I am learning docker-compose. So, I make a docker-compose file where I first pull a Postgres image and connect that Postgres to my application jar.
But I am unable to do that. Only postgres-service was running in Docker-compose. Backend_application service was Exited. I did not find out the problem. Because when I ran the application locally, it got the connection with this postgres-serivce.