Docker Community Forums

Share and learn in the Docker community.

Configuring non-default IP addresses for web addressable Docker containers

docker

(Mike812) #1

Is there a step-by-step set of directions for configuring an IP address for a Docker container to be accessible (via an Apache web service) in the network on a host separate from the Docker server? I know how to install and run Apache in a Docker container. With two Docker servers, the Docker containers are getting the same IP addresses even though they are on different servers. They seem to route to the same docker0 interface of the Docker server.

I have one Docker container on each Docker server. Each Docker server runs CentOS 7 and Docker 1.9.
I have installed Apache on both of them. I want to use curl on each one to copy files over the other. Given that they have the same IP addresses, I don’t know where to begin.

Do I need to destroy the containers and use a flag with docker run such as “–bip=x.x.x.x/24”?

(where x.x.x.x is the IP address I want to give to the new container that I am creating)

The IP address and subnet mask of each CentOS server is totally incompatible for standard TCP/IP connectivity for the IP addresses that the Docker containers have.

Must I create a network bridge and setup NAT? Or just use the Docker network overlay? Please provide thorough directions if I have provided enough details.


(Jeff Anderson) #2

The overlay network driver was built specifically to address this very usecase-- intercontainer communication between docker hosts.

Alternatively, you could publish the port on one and then connect to that from the other.