Skip to content
Sangyun Han edited this page Oct 13, 2019 · 7 revisions

This document is written by Sangyun Han.

What is LXC?

LXC(LinuX Container) is well-known low level linux container runtime. It used to be a part of Docker runtime, but not now.

Prerequisite(Environment)

$ uname -r
5.0.0-29-generic

$ lsb_release -a
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic

1. Download LXC source code

$ git clone https://github.com/lxc/lxc.git
$ cd lxc/

2. Install dependencies of build system

$ sudo apt-get install automake
$ sudo apt-get install autotools-dev
$ sudo apt-get install libcap-dev

if occurs some errors, please install these modules

3. Build LXC

$ ./autogen.sh
$ ./configure CFLAGS='-pg -g'
$ make
$ sudo make install

sudo cp /usr/local/lib/liblxc* /usr/lib/x86_64-linux-gnu

Download container image(rootfs) and Create a container based on the image Need root permission for controlling LXC system.

# If you need, please enter this.
$ sudo su
$ lxc-create -t download -n my-container
Setting up the GPG keyring
Downloading the image index

---
DIST	RELEASE	ARCH	VARIANT	BUILD
---
...
ubuntu	xenial	amd64	default	20190921_07:42
ubuntu	xenial	arm64	default	20190921_07:42
ubuntu	xenial	armhf	default	20190921_08:07
ubuntu	xenial	i386	default	20190921_07:42
ubuntu	xenial	ppc64el	default	20190921_07:42
ubuntu	xenial	s390x	default	20190921_07:42
---

Distribution:
ubuntu
Release:
xenial
Architecture:
amd64

Please enter the desired image information.

Check a list of containers

$ lxc-ls
my-container

Using uftrace

$ uftrace lxc-ls
# If need, install bridge-utils
$ sudo apt-get install bridge-utils
$ brctl addbr lxcbr0

# Or
$ vi /usr/local/var/lib/lxc/my-container/config
lxc.net.0.type = veth -> lxc.net.0.type = none

Start created, but stopped container

$ sudo lxc-start -n my-container -d
Clone this wiki locally