1

I have a spring application which is trying to connect postgres db (jdbc:postgresql://xxxxxxx:5432/My_DB). It connects fine when I run the jar using "java -jar app.jar" command.But when i run inside the docker container it fails to connect. Below is the command , I used to run.

docker run -p 5432:5432 my_image:latest

It looks like 5432 is not open inside the container seems. I came across a similar post for this, but didnt give any solutions. Docker container for Postgres 9.1 not exposing port 5432 to host

Any thoughts on this?

Thanks

Community
  • 1
  • 1
Rajesh
  • 115
  • 1
  • 3
  • 12

1 Answers1

4

You have to specifically user Expose 5432 in your docker file. Otherwise it is not allowed to expose it via a container.

Miad Abrin
  • 952
  • 7
  • 14