Skip to content

Support extended network topologies #85

Closed

Description

@jpetazzo

@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 guest container, adding a special option to our special "docker init", telling it to wait for eth42;
  • guest starts, and the docker init waits instead of executing the command specified by docker run;
  • docker starts a networksetup container, telling it to setup eth42 for container guest (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/net to /var/run/netns/<something>);
  • networksetup creates eth42 somehow, and "plumbs" it as needed;
  • when networksetup exits, docker accesses the network namespace through /var/run/netns/<something>, and moves eth42 to guest;
  • docker unmounts /var/run/netns/<something> (which reclaims the network namespace);
  • docker tells guest to 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 networksetup to grab the interface, instead of waiting for the process termination;
  • we could also want one single networksetup container 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

  1. JeremyGrosser commented on Mar 17, 2013

    @JeremyGrosser
    Contributor

    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.

  2. chooper commented on Mar 19, 2013

    @chooper
    Contributor

    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:

    • Other protocols besides TCP
    • Things that don't work well behind NAT
    • Applications that require an unknown or arbitrary number of open ports
    • Network technologies that could be in use by service providers (think VLANs and so-on)
  3. rockymadden commented on May 14, 2013

    @rockymadden

    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.

  4. jpetazzo commented on May 14, 2013

    @jpetazzo
    ContributorAuthor

    Here's something that might be useful to achieve software-defined networking with containers (and therefore, docker): https://gist.github.com/jpetazzo/5493295

  5. rockymadden commented on May 15, 2013

    @rockymadden

    @jpetazzo Seriously cool, exactly what I was looking for!

  6. shykes commented on Jul 17, 2013

    @shykes
    Contributor

    Closing the issue for focus. Feel free to continue the discussion on the mailing list, or a wiki page.

  7. added a commit that references this issue on Mar 23, 2016
  8. added a commit that references this issue on Nov 29, 2018
  9. added a commit that references this issue on Sep 12, 2022
  10. added a commit that references this issue on Sep 29, 2022
  11. added a commit that references this issue on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions