Building Oracle Enteprise in LXD

So LXD is the technology that is finally going to give the required isolation enterprise containers need, but at the same time preserver the fantastic bare metal performance of LXC Linux containers.

Today I finally installed LXD on my Ubuntu desktop and got Oracle Linux 6 and Oracle Linux 7 images installed locally on my Lenovo P70 laptop running Ubuntu 16.04.  I also configured my first Oracle 7 container to use OpenvSwitch networking and VLAN tags.  Here are my WIP notes on how to do this.

Install LXD

A very good guide on installing LXD that worked for me is here at Linux Containers (LXD) as an Alternative to VirtualBox for WordPress Development by Rob Blake.  I followed this guide verbatim except for the bit below pulling down the Oracle Linux 6 and Oracle Linux 7 images.  Rob's code would not work for me for whatever reason and I had to trial and error with it until I got a command line that successfully pulled down the Oracle Linux 6 and Oracle Linux 7 images to my local machine from the Canonical repository.

There were a couple of things that I had to figure out on my own though when it came to pulling down an Oracle Linux 6 and Oracle Linux 7 image to my laptop.

The command I used to pull down Oracle LInux 6 and Oracle Linux 7 images is shown below.

lxc image copy images:oracle/7 local: --alias=oracle/7
lxc image copy images:oracle/6 local: --alias=oracle/6
Once this is done they can be listed to verity them as shown below.

oracle@g70:~$ lxc image list
|  ALIAS   | FINGERPRINT  | PUBLIC |           DESCRIPTION           |  ARCH  |   SIZE   |         UPLOAD DATE          |
| oracle/6 | dd50d7f5b619 | no     | Oracle 6 amd64 (20160920_11:40) | x86_64 | 246.84MB | Sep 20, 2016 at 5:08pm (UTC) |
| oracle/7 | ad1d975af5be | no     | Oracle 7 amd64 (20160920_11:40) | x86_64 | 167.19MB | Sep 20, 2016 at 5:06pm (UTC) |

Now you have images to build an LXD lighter-visor Oracle Linux container.

Build Oracle Linux 7 LXD Container

These commands create the LXD containers lxdora7a, list it after it's created, and the last command connects to lxdora7a.

 lxc launch oracle/7 lxdora7a
 lxc list
 lxc exec lxdora7a /bin/bash

Running LXD Containers on OpenvSwitch

One thing I didn't capture for the purposes of this blog is the setup to tell LXD to use OpenvSwitch network.  That is done as part of the install step at this command step.

sudo lxd init

I will do this step again soon on another machine and capture all the screenshots for this blog.  It's pretty straightforward though.  The details of running "sudo lxd init" are covered here  I didn't capture the screenshots as mentioned but I will very soon and post them here.  It's straightforward though.   As I recall I gave it the IP address of my OpenvSwitch sw1 ( and then some GUI type pages opened and I told it to use bridge sw1 instead of the default lxcbr0.

Configuring the LXD Container for OpenvSwitch

This is a WIP but I got it working, albeit not as elegantly as desired.  Use the command "lxc config edit containername" to make the required changes for openvswitch networking.  I've already made the changes so below is listed the current config of my container which works with openvswitch.  Note that the credit for this bit of config code to put the LXD container on OpenvSwitch goes to a post here by Nagri.  If you are not using VLAN's on your OpenvSwitch, then this config change should put you in business.  If your network IP is handed out via dhcp (the default) then it should work at this point.  You can check your /etc/sysconfig/network-scripts/ifcfg-eth0 file.  If you don't want to use dhcp, I guess you could just set up a static IP ifcfg-eth0 and I guess it would work.  Haven't had a change to test out static networking yet in LXD but I will be doing that very soon because I plan to build Oracle Enteprise software in Oracle Linux LXD images on Ubuntu kernels.

oracle@g70:~ lxc config show lxdora7a

name: lxdora7a

- default
volatile.base_image: ad1d975af5bee4ef947ecca36084dbe2934277ed62e6a02c1fa60f1c902d2280
volatile.eth0.hwaddr: 00:16:3e:da:03:3e
volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":231072,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":231072,"Nsid":0,"Maprange":65536}]'
host_name: lxdora7a
name: eth0
nictype: bridged
parent: sw1
type: nic

path: /
type: disk
ephemeral: false


There was still more for me to do though because I VLANs on my OpenvSwitch.  I could not find a reference for how to add VLAN tagging in the lxc config file above, but I was able to manually put the VLAN tag on the port that the LXD container automatically creates when it boots using the following command after it had already booted.  At that point, eth0 is still unconfigured even though onboot is set to YES in the ifcfg-eth0 because the VLAN 10 is not passing the traffic from the LXD container lxdora7a because of the VLAN'g.

So I ran this command to put a VLAN 10 on the port after the container had already booted:

sudo ovs-vsctl set port lxdora7a tag=10

Then I logged into the container using the lxc exec lxdora7a /bin/sh command and ran "ifup eth0" which brought up the network interface, got a dhcp address from my isc-dhcp-server and updated my DNS dynamically with the DNS IP info.  Again, not an elegant solution, but at least it gets me in business.

oracle@g70:~$ nslookup lxdora7a


oracle@g70:~$ ssh root@lxdora7a
root@lxdora7a's password:
Last login: Tue Sep 20 18:42:36 2016 from

[root@lxdora7a ~]# cat /etc/resolv.conf
; generated by /usr/sbin/dhclient-script

[root@lxdora7a ~]# nslookup stlns01


[root@lxdora7a ~]#

I had to install openssh-server in the lxdora7a in order to be able to connect to it via ssh in the usual way using "yum install openssh-server".  Of course now that I had networking, that type of command requiring WAN resolution worked! 

Here's some details of what it looks like once up and running in the default state.  Just like any container, it's sharing the kernel on the LXD host which in this case is an Ubuntu 4.x kernel (Ubuntu 16.04).

[root@lxdora7a ~]# df -TH
Filesystem                  Type      Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root ext4      436G  410G  4.1G 100% /
none                        tmpfs     504k     0  504k   0% /dev
udev                        devtmpfs   34G     0   34G   0% /dev/tty
tmpfs                       tmpfs      34G     0   34G   0% /dev/shm
tmpfs                       tmpfs      34G  8.5M   34G   1% /run
tmpfs                       tmpfs      34G     0   34G   0% /sys/fs/cgroup
tmpfs                       tmpfs     6.8G     0  6.8G   0% /run/user/0
[root@lxdora7a ~]# uname -a
Linux lxdora7a 4.4.0-36-generic #55-Ubuntu SMP Thu Aug 11 18:01:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@lxdora7a ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet  netmask  broadcast
        inet6 fe80::216:3eff:feda:33e  prefixlen 64  scopeid 0x20<link>
        ether 00:16:3e:da:03:3e  txqueuelen 1000  (Ethernet)
        RX packets 14472  bytes 24012308 (22.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8483  bytes 584822 (571.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet  netmask
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@lxdora7a ~]#

And some more details below.
[root@lxdora7a ~]# cat /etc/oracle-release
Oracle Linux Server release 7.2
[root@lxdora7a ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)
[root@lxdora7a ~]#