1
votes

I created a quarkus application with access to a postgresql database on localhost. After creating the native image I try to run the application with:

docker run -i --rm -p 8080:8080 quarkusimage

if I try a method with postman I have this result:

addEmployee Hibernate: select nextval ('quarkus.hibernate_sequence') 2020-06-18 20: 43: 38,214 WARN [io.agr.pool] (Agroal_20041415421) Datasource '': Connection to localhost: 5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP / IP connections.

if i try to run the application with

docker run --net = "host" -i --rm -p 8080:8080 quarkusimage

the application accesses the database on localhost, but if I try a postman call it can't reach the service.

What am I doing wrong?

Thank you

1

1 Answers

2
votes

This has to do with docker networking. When an application is run inside docker, then localhost is not the hosts localhost unless you use --net = "host".

Aside from using --net = "host", you can could use the IP of host instead of localhost in the URL.

As for the podman issue you mention, that sounds like a podman bug or limitation - I propose you consult the podman documentation and / or open an issue in the podman issue tracker.