3

My docker host is part of the local network 192.168.178.0/24.

Is there a way to run a container that becomes a part of the host network, but does not share the same ip as the host? So for example if the host has the ip 192.168.178.5 i'd like to provide 192.168.178.8 to the container without interfering with the docker host's network configuration.

muffel
  • 7,004
  • 8
  • 57
  • 98
  • I believe this is what your looking for: [Giving a docker container a routable ip address][1] [1]: http://stackoverflow.com/questions/26539727/giving-a-docker-container-a-routable-ip-address – Hatem Jaber Jul 15 '15 at 12:26
  • @HatemJaber thanks, but I don't want NAT or a different subnet for the container (that's at least what I understand when reading the answer you've linked) – muffel Jul 15 '15 at 12:31

1 Answers1

1

since a docker container is by nature bound to use the networking stack of it's host, it also has to share the hosts IP to communicate with the network. For a one-container setup, the only solution should be to add a second NIC to the host and use that second NIC and the provided IP exclusively for your docker... But apart from that I don't see any solution that does not deeply mutilate the OSI model of your host's network stack and thus include some major side-effects :-/

  • do you mean to use the second NIC for the Docker host or just for the container? If it was possible to assign a network interface to a container, than I should be able to assign it a virtual interface with a second IP, shouldn't I? – muffel Jul 15 '15 at 16:01
  • You say you don't want NAT to be involved. So no, a virtual interface of any kind won't do it because it would still need to be exposed via your physical interface, which would need to separate traffic between it's real endpoint and your virtual NIC by somthing like NAT. Either get a second physical adapter, or you have to use some kind of NAT-mechanism to enable your host to discern the targets for network traffic – Damiano Ferrante Jul 16 '15 at 11:13