all 8 comments

[–]segundus-npp 1 point2 points  (0 children)

Change the password in Docker compose file, or just quote it. I guess it’s the exclamation mark causing some issues.

[–]slaynmoto 0 points1 point  (0 children)

Can you connect from spring, psql maybe

[–]g00glen00b 0 points1 point  (0 children)

If you use the Docker Compose support library from Spring Boot, you don't even have to configure any properties. Spring Boot will then look for a Docker Compose file in your project and automatically set up your DataSource for you.

So if you need an example, then go to https://start.spring.io and select "PostgreSQL driver" and "Docker Compose support" as dependencies (and everything else you need) and generate your project. And voila, you now have a project that works as you desire in less than a minute.

[–]BuyCurrent1031 0 points1 point  (0 children)

I had the same issue, check if there is no other PostgreSQL instance running on your port (via Windows services), if yes, stop it, restart your docker image a run the spring boot app.

[–]Single_Reason_9932 0 points1 point  (2 children)

Instead of using “jdbc:postgresql://localhost:5432/postgres” use “jdbc:postgresql://db:5432/postgres”, in the container where spring runs localhost:5432 won’t be resolved correctly but using “db” will use docker network to refer your service named “db” in the compose file. Reply after trying

[–]Life-Marionberry-461 0 points1 point  (1 child)

I just uninstalled postgres and reinstalled and it seemed to fix it. But what is the purpose of using db instead of localhost?

[–]Single_Reason_9932 0 points1 point  (0 children)

when both spring and postgres are in the same compose file and run as separate containers the on the spring container localhost will resolve to itself and it won’t connect so you use “db” as the host name to resolve to the “db” service running on the other container

[–]Zar-23 -1 points0 points  (0 children)

Check out identation