Issue
Im getting the connection refused error, but in my eclipse it connects with no problem. I wonder if it is not possible to connect to a database that hasnt been dockerized also or if its possible what should I do?
thise is my Dockerfile:
FROM openjdk:11
EXPOSE 8080
ADD target/permisos.jar permisos.jar
ENTRYPOINT ["java","-jar","/permisos.jar"]
this is my application.yml file:
spring:
profiles:
active: local
jpa:
database: POSTGRESQL
show-sql: true
hibernate:
ddl-auto: none
datasource:
platform: postgres
url: jdbc:postgresql://localhost:5432/permisosdb
username: postgres
password: postgres
driverClassName: org.postgresql.Driver
Solution
The IP address of the host is host.docker.internal
on, AFAIK, all modern Docker installations.
So your datasource URL should be
url: jdbc:postgresql://host.docker.internal:5432/permisosdb
If that doesn't work, try
url: jdbc:postgresql://172.17.0.1:5432/permisosdb
Answered By - Hans Kilian
Answer Checked By - Gilberto Lyons (JavaFixing Admin)