[ovs-discuss] Problem while trying to add bridge in a container

Gurucharan Shetty shettyg at nicira.com
Tue Feb 17 20:35:15 UTC 2015


On Tue, Feb 17, 2015 at 11:58 AM, Abhishek Chanda
<abhishek.lists at gmail.com> wrote:
> Sorry for being vague.
>
> I am trying to run neutron in a container. A container runs neutron
> and OVS in host mode.
What do you mean when you say that a container runs OVS in host mode?
Sorry for being fussy, but the above can mean different things and I
don't want to guess. So instead of you trying to frame your problem,
let me show how I can create OVS bridge inside a container.


* Create a container
root at ubuntu14:~# docker run -d  --pid=host --net=host ubuntu /bin/sh
-c "while true; do echo hello world; sleep 1;
done"6d5508adca20a4c60d9fb35c18e88170852ffe6b63775c27013188034b7a7393

* Enter the container
root at ubuntu14:~# docker-enter
6d5508adca20a4c60d9fb35c18e88170852ffe6b63775c27013188034b7a7393

* Install OVS inside the container
root at ubuntu14:~# apt-get update
Ign http://archive.ubuntu.com trusty InRelease
Ign http://archive.ubuntu.com trusty-updates InRelease
Ign http://archive.ubuntu.com trusty-security InRelease
Hit http://archive.ubuntu.com trusty Release.gpg
Get:1 http://archive.ubuntu.com trusty-updates Release.gpg [933 B]
Get:2 http://archive.ubuntu.com trusty-security Release.gpg [933 B]
Hit http://archive.ubuntu.com trusty Release
Get:3 http://archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:4 http://archive.ubuntu.com trusty-security Release [62.0 kB]
Get:5 http://archive.ubuntu.com trusty/main Sources [1335 kB]
Get:6 http://archive.ubuntu.com trusty/restricted Sources [5335 B]
Get:7 http://archive.ubuntu.com trusty/universe Sources [7926 kB]
Get:8 http://archive.ubuntu.com trusty/main amd64 Packages [1743 kB]
Get:9 http://archive.ubuntu.com trusty/restricted amd64 Packages [16.0 kB]
Get:10 http://archive.ubuntu.com trusty/universe amd64 Packages [7589 kB]
Get:11 http://archive.ubuntu.com trusty-updates/main Sources [229 kB]
Get:12 http://archive.ubuntu.com trusty-updates/restricted Sources [1874 B]
Get:13 http://archive.ubuntu.com trusty-updates/universe Sources [130 kB]
Get:14 http://archive.ubuntu.com trusty-updates/main amd64 Packages [557 kB]
Get:15 http://archive.ubuntu.com trusty-updates/restricted amd64
Packages [14.8 kB]
Get:16 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [329 kB]
Get:17 http://archive.ubuntu.com trusty-security/main Sources [86.9 kB]
Get:18 http://archive.ubuntu.com trusty-security/restricted Sources [1874 B]
Get:19 http://archive.ubuntu.com trusty-security/universe Sources [19.6 kB]
Get:20 http://archive.ubuntu.com trusty-security/main amd64 Packages [269 kB]
Get:21 http://archive.ubuntu.com trusty-security/restricted amd64
Packages [14.8 kB]
Get:22 http://archive.ubuntu.com trusty-security/universe amd64
Packages [113 kB]
Fetched 20.5 MB in 14s (1461 kB/s)
Reading package lists... Done


root at ubuntu14:~# apt-get install openvswitch-switch
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libpython-stdlib libpython2.7-minimal libpython2.7-stdlib openssl
  openvswitch-common python python-minimal python2.7 python2.7-minimal
  uuid-runtime
Suggested packages:
  ca-certificates ethtool openvswitch-datapath-module python-doc python-tk
  python2.7-doc binutils binfmt-support
The following NEW packages will be installed:
  libpython-stdlib libpython2.7-minimal libpython2.7-stdlib openssl
  openvswitch-common openvswitch-switch python python-minimal python2.7
  python2.7-minimal uuid-runtime
0 upgraded, 11 newly installed, 0 to remove and 10 not upgraded.
Need to get 5543 kB of archives.
After this operation, 23.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main
libpython2.7-minimal amd64 2.7.6-8 [307 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main python2.7-minimal
amd64 2.7.6-8 [1190 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty-updates/main openssl
amd64 1.0.1f-1ubuntu2.8 [489 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty-updates/main
uuid-runtime amd64 2.20.1-5.1ubuntu20.3 [12.2 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ trusty/main
libpython2.7-stdlib amd64 2.7.6-8 [1872 kB]
Get:6 http://archive.ubuntu.com/ubuntu/ trusty/main libpython-stdlib
amd64 2.7.5-5ubuntu3 [7012 B]
Get:7 http://archive.ubuntu.com/ubuntu/ trusty/main python2.7 amd64
2.7.6-8 [197 kB]
Get:8 http://archive.ubuntu.com/ubuntu/ trusty/main python-minimal
amd64 2.7.5-5ubuntu3 [27.5 kB]
Get:9 http://archive.ubuntu.com/ubuntu/ trusty/main python amd64
2.7.5-5ubuntu3 [134 kB]
Get:10 http://archive.ubuntu.com/ubuntu/ trusty-updates/main
openvswitch-common amd64 2.0.2-0ubuntu0.14.04.1 [444 kB]
Get:11 http://archive.ubuntu.com/ubuntu/ trusty-updates/main
openvswitch-switch amd64 2.0.2-0ubuntu0.14.04.1 [863 kB]
Fetched 5543 kB in 5s (1083 kB/s)
Selecting previously unselected package libpython2.7-minimal:amd64.
(Reading database ... 11527 files and directories currently installed.)
Preparing to unpack .../libpython2.7-minimal_2.7.6-8_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.6-8) ...
Selecting previously unselected package python2.7-minimal.
Preparing to unpack .../python2.7-minimal_2.7.6-8_amd64.deb ...
Unpacking python2.7-minimal (2.7.6-8) ...
Selecting previously unselected package openssl.
Preparing to unpack .../openssl_1.0.1f-1ubuntu2.8_amd64.deb ...
Unpacking openssl (1.0.1f-1ubuntu2.8) ...
Selecting previously unselected package uuid-runtime.
Preparing to unpack .../uuid-runtime_2.20.1-5.1ubuntu20.3_amd64.deb ...
Unpacking uuid-runtime (2.20.1-5.1ubuntu20.3) ...
Selecting previously unselected package libpython2.7-stdlib:amd64.
Preparing to unpack .../libpython2.7-stdlib_2.7.6-8_amd64.deb ...
Unpacking libpython2.7-stdlib:amd64 (2.7.6-8) ...
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../libpython-stdlib_2.7.5-5ubuntu3_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.5-5ubuntu3) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../python2.7_2.7.6-8_amd64.deb ...
Unpacking python2.7 (2.7.6-8) ...
Selecting previously unselected package python-minimal.
Preparing to unpack .../python-minimal_2.7.5-5ubuntu3_amd64.deb ...
Unpacking python-minimal (2.7.5-5ubuntu3) ...
Selecting previously unselected package python.
Preparing to unpack .../python_2.7.5-5ubuntu3_amd64.deb ...
Unpacking python (2.7.5-5ubuntu3) ...
Selecting previously unselected package openvswitch-common.
Preparing to unpack .../openvswitch-common_2.0.2-0ubuntu0.14.04.1_amd64.deb ...
Unpacking openvswitch-common (2.0.2-0ubuntu0.14.04.1) ...
Selecting previously unselected package openvswitch-switch.
Preparing to unpack .../openvswitch-switch_2.0.2-0ubuntu0.14.04.1_amd64.deb ...
Unpacking openvswitch-switch (2.0.2-0ubuntu0.14.04.1) ...
Processing triggers for mime-support (3.54ubuntu1.1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up libpython2.7-minimal:amd64 (2.7.6-8) ...
Setting up python2.7-minimal (2.7.6-8) ...
Linking and byte-compiling packages for runtime python2.7...
Setting up openssl (1.0.1f-1ubuntu2.8) ...
Setting up uuid-runtime (2.20.1-5.1ubuntu20.3) ...
Setting up libpython2.7-stdlib:amd64 (2.7.6-8) ...
Setting up libpython-stdlib:amd64 (2.7.5-5ubuntu3) ...
Setting up python2.7 (2.7.6-8) ...
Setting up python-minimal (2.7.5-5ubuntu3) ...
Setting up python (2.7.5-5ubuntu3) ...
Setting up openvswitch-common (2.0.2-0ubuntu0.14.04.1) ...
Setting up openvswitch-switch (2.0.2-0ubuntu0.14.04.1) ...
invoke-rc.d: policy-rc.d denied execution of start.
Processing triggers for ureadahead (0.100.0-16) ...

* Start OVS inside the container

root at ubuntu14:~# /etc/init.d/openvswitch-switch start
 * /etc/openvswitch/conf.db does not exist
 * Creating empty database /etc/openvswitch/conf.db
 * Starting ovsdb-server
 * Configuring Open vSwitch system IDs
 * Starting ovs-vswitchd
 * Enabling remote OVSDB managers
root at ubuntu14:~# ovs-vsctl show
76eb6660-c7ac-4dc1-8ee7-ebbfeee46175
    ovs_version: "2.0.2"
root at ubuntu14:~# ovs-vsctl add-br br0
root at ubuntu14:~# ovs-vsctl show
76eb6660-c7ac-4dc1-8ee7-ebbfeee46175
    Bridge "br0"
        Port "br0"
            Interface "br0"
                type: internal
    ovs_version: "2.0.2"
root at ubuntu14:~#
root at ubuntu14:~# ip link show br0
807: br0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
mode DEFAULT group default
    link/ether 0a:e2:0e:ca:f3:47 brd ff:ff:ff:ff:ff:ff
root at ubuntu14:~#
root at ubuntu14:~#

* Exit the container and see whether "br0" is visible inside the host

root at ubuntu14:~# exit
logout
root at ubuntu14:~# ip link show br0
807: br0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
mode DEFAULT group default
    link/ether 0a:e2:0e:ca:f3:47 brd ff:ff:ff:ff:ff:ff
root at ubuntu14:~#



More information about the discuss mailing list