1

I have installed docker on a private cloud VM (RHEL 7.2) with a floating IP say 10.135.118.6
I also have a Java Play Application which talks to third party database servers. The database have white-listed the floating IP 10.135.118.6 so that my Java Play App can make a connection to it.

Now I wish to dockerize this Java Play App, but while doing so, the IP addresses which get assigned to the docker containers are mapped using a default docker bridge whose IPs eventually turn out to be of the range 172.17.0.2 (Dynamic IP)

This is creating a problem for me as my new IP is not white-listed on my Database server which eventually stops the container.

Is there any way I can assign the VM floating IP to my docker container instead of the docker bridge network IP?

  • 1
    You can use the network type host for the container. See [Network drivers](https://docs.docker.com/network/#network-drivers). – Charles Xu Sep 18 '18 at 09:33

1 Answers1

0

To achieve this:

First, you can create your own docker network with custom subnet(e.g JavaPlay_net)

docker network create --subnet=172.32.0.0/16 JavaPlay_net

than simply run the image (for example ubuntu image)

docker run --net JavaPlay_net --ip 172.32.0.22 -it ubuntu bash

then in ubuntu shell

hostname -i

Additionally you could use

  • --hostname to specify a hostname

  • --add-host to add more entries to /etc/hosts

Reference to create Docker Network:

https://docs.docker.com/engine/reference/commandline/network_create/#options