Repository navigation
Description
@synack asked support for advanced network topologies; e.g. using openvswitch to interconnect containers running on multiple hosts, as if they were all running on a flat network.
I experimented a bit with the netns options of ip, and here are some notes which will hopefully be useful when we want to tackle this feature.
It's already well-known that you can setup an interface (e.g. iface0) in the host, then move it to the guest, with ip link set iface0 netns 1234 where 1234 is the PID of a process in the guest.
It's also possible to move this interface back, by running ip netns exec 1234 ip link set iface0 netns 1. That's because ip netns exec only sets the network namespace: it doesn't touch the mnt namespace (so executing ip will always execute the local, well-known, trusted ip command) nor the pid namespace (so pid 1 is our local, well-known, init process, and its namespace is probably our namespace, if we didn't do funky things in between; in doubt we could also use $$ instead!)
After discussing the matter with @shykes, we are considering the idea that the setup of "special interfaces" should be handled by another container. The point is that all the required tools (openvpn, vde, ...) can be setup in another container, instead of handling dependencies etc. in the host.
Example workflow, assuming that you want a special interface eth42 in guest:
- docker starts the
guestcontainer, adding a special option to our special "docker init", telling it to wait foreth42; gueststarts, and the docker init waits instead of executing the command specified bydocker run;- docker starts a
networksetupcontainer, telling it to setupeth42for containerguest(it might provide this in a special payload, with other parameters); - before actually executing the process, docker should somehow retain the network namespace of
networksetup(with a bind-mounting of/proc/<pid>/ns/netto/var/run/netns/<something>); networksetupcreateseth42somehow, and "plumbs" it as needed;- when
networksetupexits, docker accesses the network namespace through/var/run/netns/<something>, and moveseth42toguest; - docker unmounts
/var/run/netns/<something>(which reclaims the network namespace); - docker tells
guestto go on.
If eth42 depends on networksetup to run (e.g. OpenVPN or VDE), we have the following options:
- add some option to tell docker that it should wait for a signal from
networksetupto grab the interface, instead of waiting for the process termination; - we could also want one single
networksetupcontainer to handle everything (to save resources?), and in that case, we need some communication between docker and this container.
Also, if eth42 actually depends on resources located in the root namespace (e.g. tagged VLANs on a physical interface), it could be great to give the possibility to run networksetup in the host netns. (So that's one more flag, and it might be challenging or even impossible to achieve that with basic lxc-start... But still, it's worth mentioning.)
(Sorry if that's too much technical/implementation detail!)
Activity
JeremyGrosser commentedon Mar 17, 2013
I'm not sure that running everything in a networksetup container is feasible... Many of the types of things you'd want to do require kernel modules, eg. tuntap for openvpn, wireless drivers, routing protocol handlers, etc. In the case of openvswitch it potentially needs datapath and brcompat, which requires unloading the default "bridge" module that gets autoloaded when lxc is installed.
chooper commentedon Mar 19, 2013
I would actually to prefer to see something like a "dumb" networking mode that just slices off an interface and doesn't do anything else (adding it to a bridge would have to happen out-of-band).
I know that part of the power of docker is that "it just works," but I can imagine a variety of use cases that leave it preferable to manage the networking out of band. I think our job is to make an API that's going to be usable by out-of-band management. Things to consider:
rockymadden commentedon May 14, 2013
I have little to add to the discussion that hasn't already been said, however I would like to voice that this enhancement is on the top of my own list before I can leverage docker to its full potential.
Wonderful project, BTW.
jpetazzo commentedon May 14, 2013
Here's something that might be useful to achieve software-defined networking with containers (and therefore, docker): https://gist.github.com/jpetazzo/5493295
rockymadden commentedon May 15, 2013
@jpetazzo Seriously cool, exactly what I was looking for!
shykes commentedon Jul 17, 2013
Closing the issue for focus. Feel free to continue the discussion on the mailing list, or a wiki page.
Merge pull request moby#85 from nalind/journal-fedora-1.10.3
Merge pull request moby#85 from thaJeztah/18.09_backport_deprecated_s…
Merge pull request moby#85 from ndeloof/tag_labels
Merge pull request moby#85 from ndeloof/tag_labels
Merge pull request moby#85 from aboch/drv