The application server has been running in docker container could not use postgresql dirver.Connection refused

I am trying to use JDBC to connect to Postgresql database.the error happens while trying to make a database connection.

conn = DriverManager.getConnection(url, user, password);

I deploy war file into wildfly that is docker container.
when I call the connect() method the error occur.
this is my pom.xml:

docker file:
Docker File
the Java code for JDBC connection:
JDBC connection

and while the wildfly is lunching there is always this warning that I guess is relevant to the connection refused Error:

Could not index class org/postgresql/jdbc/PgConnection$1.class at
java.lang.IllegalStateException: Required class information is missing

these two picture are intellij project structure and artifact that has postgres driver library in its lib.
Project structure
Project structure Artifact

Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
22:51:20,921 ERROR [io.undertow.request] (default task-1) 
  UT005023: Exception handling request to /corsan/: java.lang.NullPointerException  

when I deploy the war directly to the same application server in local it works fine. But when I use docker container this issue occure. I really appreciate for any hint or help because I really stuck in this part.

Source: Docker Questions