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?

4

1 回答 1

0

为达到这个:

首先,您可以使用自定义子网创建自己的 docker 网络(例如 JavaPlay_net)

docker network create --subnet=172.32.0.0/16 JavaPlay_net

而不是简单地运行图像(例如 ubuntu 图像)

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

然后在ubuntu shell中

hostname -i

此外,您可以使用

  • --hostname指定主机名

  • --add-host向 /etc/hosts 添加更多条目

创建 Docker 网络的参考:

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

于 2018-09-18T10:24:20.480 回答