Two Docker containers on different VMs share an IP address on the network

What do I do about two Docker containers on separate VMs that have the same IP address on my network?

I have two CentOS 7.x servers. Both have exactly one Docker container. When I use ifconfig, the docker0 instance has the same IP address on each server. Will this cause a problem?

I used the Docker inspect command to determine the IP address of each container. The containers have the same IP address. How do I give them unique IP addresses? Maybe it isn’t necessary.

My goal is to make one container a yum repository server and the other a client. I want to test the client with yum commands. It currently does not work. The client will have an /etc/yum.repos.d/special.repo file. For the baseurl stanza, should I use FTP or HTTP? If I choose HTTP, must the repo server run a web service?

How is the file constructor of the baseurl stanza created? I looked at different repo files on client servers. But they were for web-based repos. Is the path based on the / directory of the Linux server.

I know how to create the repo (e.g., put the .rpm files in a directory, then run createrepo /mnt/specialrepo). I just don’t know what the path of the file constructor should be like in the special.repo file for the baseurl on the client server (e.g. x.x.x.x/mnt/specialrepo).

Basically, when you’re using the docker0 default network, each docker host has its own private network that the containers are connected to. If communications were to happen between the two hosts, you would need to publish the ports, and then connect to the IP of the VM on the published port.

Alternatively, if you want those containers to be on the same network, you could create an overlay network, and then containers on both hosts would be assigned ip addresses from the same pool.

How do I publish the ports? Ports 1 through 1000 are not blocked in my network or on any server.

How do I create an overlay network? After that is created, how would I assign IP addresses to the containers?

This is probably the best place to get started on docker networks:

The basic gist is you’ll need to have all engines be configured with a common kv store, and then you’ll run docker network create -d overlay mynetwork. You’ll then be able to run containers like this: docker run --net=mynetwork .... The v2 format of the docker-compose.yml syntax also supports declaring networks.

As far as ip address management, you can pretty much let docker do its thing. If for whatever reason the default docker ip address management doesn’t work for you, you can specify a conatiner ip address with the --ip option, or even provide your own IPAM plugin. Most users don’t need to worry about managing the IP addresses of their containers though.