I have created a Spring Boot project connected to PostgreSQL. When running the project and connecting from my IDE, the PostgreSQL I installed within Docker is working fine.
I use Docker Desktop version 4.6.1 on Windows 11, and I have faced two problems when starting docker.
First:
docker run --name myapp --network=host -d 220d023bd426
For the command above, the application is starting, but I can't access it from the outside like Postman, then I try
docker exec -it 099583cc05b6 /bin/bash
and use curl to test it works.
Second:
docker run --name myapp -p 8181:8080 -d 220d023bd426
For command above, it shows an error:
org.postgresql.util.PSQLException: Connection to 127.0.0.1:6543 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP