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).

  • just out of curiosity...are you in a "devops team"? and are you the programmer dumped with all the sysadmin type jobs so that your employer doesn't have to waste good money on hiring a sysadmin? if so, tell your boss that devops isn't supposed to work like that. also tell him to hire an actual sysadmin. – cas Apr 12 '16 at 3:28
  • Why would you need to give docker containers separate IPs manually, if they reside on different VMs? In production you can just use IPs of VMs and docker containers can be mapped to VM's external ports. Or you can just assign server names to each of your containers. In development (if you run both containers on the same physical machine) and your consumer container needs to access repository container, just use docker run -d --link=repository:repository consumer-image so that --link flag passes server name of repository into consumer's /etc/hosts. – Boris Burkov Apr 12 '16 at 14:17
  • The containers used the same image. So the docker run command wouldn't uniquely identify the consumer container. I have set up both containers on one VM. Later I'll use containers on different VMs. How would I map the ports to the Docker containers? How does the --link flag pass the server name of the repository into the consumer's /etc/hosts file? – Kiran Apr 12 '16 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.