Below is the topology I am trying to create with mininet(containernet) where there are 3 containers with a layer 2 switch in between. I want to access these containers (eg. kali linux container) on the localhost on the browser. I tried exposing the ports like it says in the documentation but still I cannot access it on the browser.
Note- I can access the containers (eg kali linux conatiner) if I dont use containernet on localhost.
For reference 3rd host uses the following docker container- https://hub.docker.com/r/lukaszlach/kali-desktop
#!/usr/bin/python
from mininet.net import Containernet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.log import info, setLogLevel
#VNC_DEFAULT = 5900
#WEB_DEFAULT = 6080
setLogLevel('info')
net = Containernet(controller=Controller)
info('*** Adding controller
')
net.addController('c0' )
info('*** Adding docker containers
')
d1 = net.addDocker('d1', ip='10.0.2.16', dimage="virtualmogli_v1_service1", ports=[5000], port_bindings={5000:5000},publish_all_ports=True)
d2 = net.addDocker('d2', ip='10.0.2.15', dimage="virtualmogli_v1_service2", ports=[5001], port_bindings={5001:5001},publish_all_ports=True)
d3 = net.addDocker('d3', ip='10.0.2.17', dimage="virtualmogli_v1_kalicontainer", ports=[5900, 6080], port_bindings={5900: 5900, 6080: 6080}, publish_all_ports=True,)
info('*** Adding switches
')
s1 = net.addSwitch('s1')
#s2 = net.addSwitch('s2')
info('*** Creating links
')
net.addLink(d1, s1, cls=TCLink, delay='100ms', bw=1)
#net.addLink(s1, s2, cls=TCLink, delay='100ms', bw=1)
net.addLink(s1, d2, cls=TCLink, delay='100ms', bw=1)
net.addLink(s1, d3, cls=TCLink, delay='100ms', bw=1)
info('*** Starting network
')
net.start()
info('*** Testing connectivity
')
net.ping([d1, d2, d3])
info('*** Running CLI
')
CLI(net)
info('*** Stopping network')
net.stop()
question from:
https://stackoverflow.com/questions/65902549/how-to-expose-mininet-containernet-host-ports-to-launch-application-on-localho 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…