Installing LXC & LXD on Ubuntu 16.04 LTS

Shahriar Shovon

Supported OS

  • Ubuntu 16.04 - Xenial Xerus

Categories

Share this post with your friends

If you want to use Ubuntu to follow this LXC/LXD tutorial, then I recommend you to use recent version of Ubuntu. Ubuntu 16.04 LTS or higher should be okay. I am using Ubuntu 16.04 LTS for this tutorial series. Setting up LXC and LXD on Ubuntu is really easy.

Installing LXC on Ubuntu

You can run the following commands to install LXC on Ubuntu through apt. sudo apt update sudo apt install lxc -y Reading package lists... Done Building dependency tree... 0% Building dependency tree Reading state information... Done The following additional packages will be installed: bridge-utils cloud-image-utils debootstrap distro-info genisoimage libaio1 libboost-iostreams1.58.0 libboost-random1.58.0 libboost-system1.58.0 libboost-thread1.58.0 libiscsi2 libnspr4 libnss3 libnss3-nssdb libpam-cgfs librados2 librbd1 lxc-templates lxc1 python3-lxc qemu-block-extra qemu-utils sharutils Suggested packages: cloud-utils-euca shunit2 wodim cdrkit-doc qemu-user-static lxctl bsd-mailx | mailx The following NEW packages will be installed: bridge-utils cloud-image-utils debootstrap distro-info genisoimage libaio1 libboost-iostreams1.58.0 libboost-random1.58.0 libboost-system1.58.0 libboost-thread1.58.0 libiscsi2 libnspr4 libnss3 libnss3-nssdb libpam-cgfs librados2 librbd1 lxc lxc-templates lxc1 python3-lxc qemu-block-extra qemu-utils sharutils 0 upgraded, 24 newly installed, 0 to remove and 0 not upgraded. Need to get 6,987 kB of archives. After this operation, 26.5 MB of additional disk space will be used. Get:1 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libiscsi2 amd64 1.12.0-2 [51.5 kB] Get:2 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 bridge-utils amd64 1.5-9ubuntu1 [28.6 kB] Get:3 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 distro-info amd64 0.14build1 [20.0 kB] Get:4 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 genisoimage amd64 9:1.1.11-3ubuntu1 [316 kB] Get:5 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libaio1 amd64 0.3.110-2 [6,356 B] Get:6 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libboost-iostreams1.58.0 amd64 1.58.0+dfsg-5ubuntu3 [28.8 kB] Get:7 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libboost-system1.58.0 amd64 1.58.0+dfsg-5ubuntu3 [9,038 B] Get:8 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libboost-random1.58.0 amd64 1.58.0+dfsg-5ubuntu3 [11.7 kB] Get:9 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libboost-thread1.58.0 amd64 1.58.0+dfsg-5ubuntu3 [47.0 kB] Get:10 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libnspr4 amd64 2:4.11-1ubuntu1 [112 kB] Get:11 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libnss3-nssdb all 2:3.21-1ubuntu4 [10.6 kB] Get:12 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libnss3 amd64 2:3.21-1ubuntu4 [1,129 kB] Get:13 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 libpam-cgfs amd64 2.0.0-0ubuntu2 [9,064 B] Get:14 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 librados2 amd64 10.1.2-0ubuntu1 [1,631 kB] Get:15 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 librbd1 amd64 10.1.2-0ubuntu1 [2,070 kB] Get:16 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 python3-lxc amd64 2.0.0-0ubuntu2 [20.1 kB] Get:17 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 lxc1 amd64 2.0.0-0ubuntu2 [589 kB] Get:18 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 lxc all 2.0.0-0ubuntu2 [3,082 B] Get:19 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 lxc-templates amd64 2.0.0-0ubuntu2 [81.6 kB] Get:20 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 qemu-block-extra amd64 1:2.5+dfsg-5ubuntu10 [30.7 kB] Get:21 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 qemu-utils amd64 1:2.5+dfsg-5ubuntu10 [579 kB] Get:22 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 sharutils amd64 1:4.15.2-1 [148 kB] Get:23 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 cloud-image-utils all 0.27-0ubuntu24 [15.8 kB] Get:24 http://mirror.linuxeveryday.home/ubuntu xenial/main amd64 debootstrap all 1.0.78+nmu1ubuntu1 [37.8 kB] Fetched 6,987 kB in 2s (3,244 kB/s) Selecting previously unselected package libiscsi2:amd64. (Reading database ... 59342 files and directories currently installed.) Preparing to unpack .../libiscsi2_1.12.0-2_amd64.deb ... Unpacking libiscsi2:amd64 (1.12.0-2) ... Selecting previously unselected package bridge-utils. Preparing to unpack .../bridge-utils_1.5-9ubuntu1_amd64.deb ... Unpacking bridge-utils (1.5-9ubuntu1) ... Selecting previously unselected package distro-info. Preparing to unpack .../distro-info_0.14build1_amd64.deb ... Unpacking distro-info (0.14build1) ... Selecting previously unselected package genisoimage. Preparing to unpack .../genisoimage_9%3a1.1.11-3ubuntu1_amd64.deb ... Unpacking genisoimage (9:1.1.11-3ubuntu1) ... Selecting previously unselected package libaio1:amd64. Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ... Unpacking libaio1:amd64 (0.3.110-2) ... Selecting previously unselected package libboost-iostreams1.58.0:amd64. Preparing to unpack .../libboost-iostreams1.58.0_1.58.0+dfsg-5ubuntu3_amd64.deb ... Unpacking libboost-iostreams1.58.0:amd64 (1.58.0+dfsg-5ubuntu3) ... Selecting previously unselected package libboost-system1.58.0:amd64. Preparing to unpack .../libboost-system1.58.0_1.58.0+dfsg-5ubuntu3_amd64.deb ... Unpacking libboost-system1.58.0:amd64 (1.58.0+dfsg-5ubuntu3) ... Selecting previously unselected package libboost-random1.58.0:amd64. Preparing to unpack .../libboost-random1.58.0_1.58.0+dfsg-5ubuntu3_amd64.deb ... Unpacking libboost-random1.58.0:amd64 (1.58.0+dfsg-5ubuntu3) ... Selecting previously unselected package libboost-thread1.58.0:amd64. Preparing to unpack .../libboost-thread1.58.0_1.58.0+dfsg-5ubuntu3_amd64.deb ... Unpacking libboost-thread1.58.0:amd64 (1.58.0+dfsg-5ubuntu3) ... Selecting previously unselected package libnspr4:amd64. Preparing to unpack .../libnspr4_2%3a4.11-1ubuntu1_amd64.deb ... Unpacking libnspr4:amd64 (2:4.11-1ubuntu1) ... Selecting previously unselected package libnss3-nssdb. Preparing to unpack .../libnss3-nssdb_2%3a3.21-1ubuntu4_all.deb ... Unpacking libnss3-nssdb (2:3.21-1ubuntu4) ... Selecting previously unselected package libnss3:amd64. Preparing to unpack .../libnss3_2%3a3.21-1ubuntu4_amd64.deb ... Unpacking libnss3:amd64 (2:3.21-1ubuntu4) ... Selecting previously unselected package libpam-cgfs. Preparing to unpack .../libpam-cgfs_2.0.0-0ubuntu2_amd64.deb ... Unpacking libpam-cgfs (2.0.0-0ubuntu2) ... Selecting previously unselected package librados2. Preparing to unpack .../librados2_10.1.2-0ubuntu1_amd64.deb ... Unpacking librados2 (10.1.2-0ubuntu1) ... Selecting previously unselected package librbd1. Preparing to unpack .../librbd1_10.1.2-0ubuntu1_amd64.deb ... Unpacking librbd1 (10.1.2-0ubuntu1) ... Selecting previously unselected package python3-lxc. Preparing to unpack .../python3-lxc_2.0.0-0ubuntu2_amd64.deb ... Unpacking python3-lxc (2.0.0-0ubuntu2) ... Selecting previously unselected package lxc1. Preparing to unpack .../lxc1_2.0.0-0ubuntu2_amd64.deb ... Unpacking lxc1 (2.0.0-0ubuntu2) ... Selecting previously unselected package lxc. Preparing to unpack .../lxc_2.0.0-0ubuntu2_all.deb ... Unpacking lxc (2.0.0-0ubuntu2) ... Selecting previously unselected package lxc-templates. Preparing to unpack .../lxc-templates_2.0.0-0ubuntu2_amd64.deb ... Unpacking lxc-templates (2.0.0-0ubuntu2) ... Selecting previously unselected package qemu-block-extra:amd64. Preparing to unpack .../qemu-block-extra_1%3a2.5+dfsg-5ubuntu10_amd64.deb ... Unpacking qemu-block-extra:amd64 (1:2.5+dfsg-5ubuntu10) ... Selecting previously unselected package qemu-utils. Preparing to unpack .../qemu-utils_1%3a2.5+dfsg-5ubuntu10_amd64.deb ... Unpacking qemu-utils (1:2.5+dfsg-5ubuntu10) ... Selecting previously unselected package sharutils. Preparing to unpack .../sharutils_1%3a4.15.2-1_amd64.deb ... Unpacking sharutils (1:4.15.2-1) ... Selecting previously unselected package cloud-image-utils. Preparing to unpack .../cloud-image-utils_0.27-0ubuntu24_all.deb ... Unpacking cloud-image-utils (0.27-0ubuntu24) ... Selecting previously unselected package debootstrap. Preparing to unpack .../debootstrap_1.0.78+nmu1ubuntu1_all.deb ... Unpacking debootstrap (1.0.78+nmu1ubuntu1) ... Processing triggers for man-db (2.7.5-1) ... Processing triggers for libc-bin (2.23-0ubuntu3) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for install-info (6.1.0.dfsg.1-5) ... Setting up libiscsi2:amd64 (1.12.0-2) ... Setting up bridge-utils (1.5-9ubuntu1) ... Setting up distro-info (0.14build1) ... Setting up genisoimage (9:1.1.11-3ubuntu1) ... Setting up libaio1:amd64 (0.3.110-2) ... Setting up libboost-iostreams1.58.0:amd64 (1.58.0+dfsg-5ubuntu3) ... Setting up libboost-system1.58.0:amd64 (1.58.0+dfsg-5ubuntu3) ... Setting up libboost-random1.58.0:amd64 (1.58.0+dfsg-5ubuntu3) ... Setting up libboost-thread1.58.0:amd64 (1.58.0+dfsg-5ubuntu3) ... Setting up libnspr4:amd64 (2:4.11-1ubuntu1) ... Setting up libpam-cgfs (2.0.0-0ubuntu2) ... Setting up python3-lxc (2.0.0-0ubuntu2) ... Setting up lxc1 (2.0.0-0ubuntu2) ... Setting up lxc dnsmasq configuration. Setting up lxc (2.0.0-0ubuntu2) ... Setting up lxc-templates (2.0.0-0ubuntu2) ... Setting up sharutils (1:4.15.2-1) ... Setting up debootstrap (1.0.78+nmu1ubuntu1) ... Setting up libnss3-nssdb (2:3.21-1ubuntu4) ... Setting up libnss3:amd64 (2:3.21-1ubuntu4) ... Setting up librados2 (10.1.2-0ubuntu1) ... Setting up librbd1 (10.1.2-0ubuntu1) ... Setting up qemu-block-extra:amd64 (1:2.5+dfsg-5ubuntu10) ... Setting up qemu-utils (1:2.5+dfsg-5ubuntu10) ... Setting up cloud-image-utils (0.27-0ubuntu24) ... Processing triggers for libc-bin (2.23-0ubuntu3) ... Processing triggers for ureadahead (0.100.0-19) ...

Installing LXD on Ubuntu

Run the following command to install LXD. sudo apt install lxd -y There's a change that LXD will be installed when you installed LXC. Still, I wanted to make sure that everything is installed. In that case, you should see the following output. Reading package lists... Done Building dependency tree Reading state information... Done lxd is already the newest version (2.0.0-0ubuntu4). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. You can run the following command to check if LXD is installed correctly. lxc version 2.0.0 LXC and LXD is installed correctly. See you in my next post.