Docker Community Forums

Share and learn in the Docker community.

OVS-Docker keeping configuration after reboot/ on startup

Hello,
I’m having trouble keeping connection between docker containers and ovs bridge after reboot.
I’m using debian.
So to re-create

I install openvswitch-switch, docker, ovs-docker addon.

in /etc/network/interfaces I delete eth0 configuration and instead add
#-----------------------------------------------
allow-ovs sw01
iface sw01 inet static
address 192.168.1.220
netmask 255.255.255.0
gateway 192.168.1.1
ovs_type OVSBridge
ovs_ports eth0

allow-sw01 eth0
iface eth0 inet manual
ovs_bridge sw01
ovs_type OVSPort
#---------------------------------------
I save and reboot system.
Great now i have a ovs bridge with IP and it works :stuck_out_tongue:

Time for docker container:

docker run -itd --name=container1 --net=none --restart=always ubuntu

image is running with no network.

now I use ovs-docker to connect the networkless container1 to my network

ovs-docker add-port sw01 eth0 container1 --ipaddress=192.168.1.5/24 --gateway=192.168.1.1

and now the container is available on ip 192.168.1.5. I can ping it, it can ping me. It can also access ip addresses outside this subnet via GW, and that indicates that it all works.

But now, if i reboot the system (or shutdown…) after startup the connection between sw01 and container1 is gone(container is running, bridge network is good). and I can get it back by executing command :
ovs-docker add-port sw01 eth0 container1 --ipaddress=192.168.1.5/24 --gateway=192.168.1.1
again.
My question is, is there a way to keep this link up automatically after every reboot?