-2

I am trying to build a dynamic virtual network with ONOS SDN. Until this point I successfully deployed a network with ONOS virtual switches and virtual hosts connected to them with Mininet. But I was trying and wondering how I could connect running docker containers to those switches, in order to build a network of containers/vms.

I accomplished to run (through Python scripts) some topologies that were present on ONOS SDN pre built VM. I am trying to enable a connection between some docker container (or even a VM) to a virtual SDN switch.

Is it possible to do something like this (connecting 2 ubuntu containers and 1 postgresql db container to the switches):

from mininet.net import Mininet
from mininet.node import Controller, Docker, OVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel

setLogLevel('info')

net = Mininet(controller=Controller, switch=OVSSwitch, autoSetMacs=True)


s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
s3 = net.addSwitch('s3')

ubuntu1 = net.addHost('ubuntu1', cls=Docker, dimage='ubuntu:latest', privileged=True)
ubuntu2 = net.addHost('ubuntu2', cls=Docker, dimage='ubuntu:latest', privileged=True)


postgres = net.addHost('postgres', cls=Docker, dimage='postgres:latest', privileged=True)


net.addLink(ubuntu1, s1)
net.addLink(ubuntu2, s3)
net.addLink(postgres, s2)

net.addLink(s1, s2)
net.addLink(s2, s3)

net.start()
controller_ip = '127.0.0.1'
controller_port = 6653
c0 = net.addController('c0', controller=RemoteController, ip=controller_ip, port=controller_port)
s1.start([c0])
s2.start([c0])
s3.start([c0])


CLI(net)


net.stop()
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Сергей Кох Mar 17 '23 at 11:54
  • Edited @СергейКох! Hoping it is more clear. – Luis Guerra Mar 17 '23 at 21:39
  • Typically, the way one connects a Docker container to a virtual switch is to connect it to a tap device one bridges to that switch. [Connect Docker interfaces to a TAP interface](https://stackoverflow.com/questions/67695843/connect-docker-containers-to-tap-interface) is one part of that. The other part, of course, is figuring out how to connect your "virtual SDN switch" to a tap device, but any serious / non-theoretical implementation will ideally already support that. – Charles Duffy Mar 17 '23 at 21:42
  • Anyhow -- there are several moving parts to this, and to have an on-topic question, you need to be asking a question that's narrowly focused on one specific thing that went wrong. "Is it possible to (accomplish some overarching goal)?" is typically too broad to be on-topic here. – Charles Duffy Mar 17 '23 at 21:44
  • (https://docs.docker.com/network/bridge/ is the upstream docs on bridged networking from the Docker end of it) – Charles Duffy Mar 17 '23 at 21:45

1 Answers1

0

Something that needs to be considered is that by default each Docker container has its own IP address, which may be used by the host machine to reach each container and is obtained using the following command:

sudo docker inspect <container_name> | grep -i ipaddress

Also consider that Docker supports different network configurations. There is a Youtube video that explains them.

D Arjona
  • 16
  • 1