Docker Container as Mininet Host

Docker seems to quite the buzz these days. It’s interesting what you could do with it, but I wanted try and see if it can help in any way when used in Mininet. A lot of times when you want to run certain applications inside a Mininet Host, you had to install that software on your PC/VM since the Mininet Host and your physical host share the same file system. This does come in handy a lot of times. But what if I don’t want to clutter up my physical host with extra apps. This seems like a great place for Docker to be used. Since Mininet uses veth pairs to connect the Mininet Host to the switches, it seemed that it wouldn’t be to hard to swap out the Mininet Host with a Docker host since Docker containers can also use veth pairs.

So I wrote a small test class to try it out. I wrote a new DockerHost class and added one to my topology.

    h1 = net.addHost( 'h1', ip='', cls=DockerHost )
    h2 = net.addHost( 'h2', ip='')

Then tried it out.

mininet@mininet:~$ sudo ./
*** Adding controller
*** Adding hosts
Removing any old host still running
Start Docker Host
*** Adding switch
*** Creating links
*** Starting network
*** Configuring hosts
h1 h2
*** Starting controller
*** Starting 1 switches
*** Running CLI
*** Starting CLI:
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)

I was quite happy to see this work. The Docker host I used is a basic Ubuntu image. So it has no special apps in it. Mininet is just starting the Docker container as such.

docker run --priviledged -h h1 --name=mininet-h1 -ti  --net='none' ubuntu /bin/bash

I can see it running here.

mininet@mininet:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
a33e763eb709        ubuntu:latest       /bin/bash           19 seconds ago      Up 18 seconds                           mininet-h1  

You can pick up the experiment and play with it here and most likely improve it. If you add applications, for the above to still work, the container needs to be started as a shell so Mininet can configure the networking inside and send other commands. So any applications that need to start automatically must be started internally, possible using the supervisord process.

A quick note/disclaimer that this is a bit of a hack still. It isn’t considered stable by any means since this was just the beginning of the experiment, but I wanted to share my success so far. So use at your own risk.

If you are able to improve it, please ping me back as I’d love to see what you did.

This post ‘Docker Container as Mininet Host’ first appeared on