I have a solution made by 3 different Java server applications.
The 3 Java applications can run on 3 different physical servers, but also on the same server (depending by number of users, traffic, etc...). They must access a Postgresql database. The database can reside either on a different physical server or on the same physical server as one of the applications.
So there could be a case where the database and the 3 java applications reside on the same physical server, while in another case they reside on 4 different physical servers.
All servers have static IP addresses.
The 3 Java applications are installed through the Docker container, while the PostgreSql DB is installed in the traditional way (without container).
The problem is that the java application sees (by 'getLocalHost()') the address of the container (172.0 ......) as its own address; because it was designed without container, itmust see the physical address of the host (80.211 .....).
Furthermore, when the Java application accesses the database, the database sees that the access request comes from the IP address 172.0... while it should receive it, to allow access, from 80.211 ....
The Java application are runned by a docker file like that:
FROM openjdk:8-oraclelinux8
WORKDIR /mydir
# VOLUME . /
COPY ["./My_name_Java_app.jar", "./My_name_Java_app.properties", "./"]
EXPOSE 80
EXPOSE 8080
EXPOSE 1000-2000
ENTRYPOINT ["/bin/java", "-Djava.awt.headless=true", "-jar", "My_name_Java_app.jar"]
How can I modify the dockerfile so that the host ip address is exposed and not the container address?