Docker Community Forums

Share and learn in the Docker community.

Assign IP in docker container


(Teknowmics) #1

Hello Everyone,

Hope you are all doing good. We are trying to build a database container for our java application. Our java application connects to MySQL database during application startup.

We have setup java app on one container and have been trying to link to DB container. Our app uses a xml file where it get the database details like username, password and IP address. How can we hard cord the ip address field of database server in xml file so that whenever we start our application container it always link to static ip of database server.

xml entry will look like as follows

    entry key="database.host">172.17.0.3</entry>
    entry key="database.port">3306</entry>
    entry key="database.username">dbuser</entry>
    entry key="database.password">secretpassword</entry>

We would like to set a static IP address for eg : 172.17.0.3 in our xml file and should be able to connect to the database server using mentioned IP.

Please advise a solution.