From Fedora Project Wiki

(+added perl to installed packages (deboostrap requires it), corrected the create command (release precise -> -r precise) and replaced precise with xenial)
Line 8: Line 8:
 
== Installation ==  
 
== Installation ==  
  
     $ sudo dnf install lxc lxc-templates lxc-extra debootstrap libvirt
+
     $ sudo dnf install lxc lxc-templates lxc-extra debootstrap libvirt debootstrap perl
  
 
The 'debootstrap' is necessary in order to build Debian-based containers.
 
The 'debootstrap' is necessary in order to build Debian-based containers.
Line 34: Line 34:
 
== Create a container ==
 
== Create a container ==
  
     # lxc-create -n container1 -t ubuntu -- release precise
+
     # lxc-create -n container1 -t ubuntu -- -r xenial
 
     # lxc-start -n container1
 
     # lxc-start -n container1
 
     # lxc-attach -n container1
 
     # lxc-attach -n container1

Revision as of 15:53, 18 November 2016

LXC (Linux Containers) is an operating system–level virtualization method for running multiple isolated Linux systems (containers) on a single control host.

Official project website: https://linuxcontainers.org


Getting started

Installation

   $ sudo dnf install lxc lxc-templates lxc-extra debootstrap libvirt debootstrap perl

The 'debootstrap' is necessary in order to build Debian-based containers.
The libvirt will provide basic networking management, such us bridge, NAT and DHCP.

After the installation, start the libvirt daemon:

   # systemctl start libvirtd

Change default bridge

Edit the file /etc/lxc/default.conf and change the parameter 'lxc.network.link' from 'lxcbr0' to 'virbr0':

   lxc.network.type = veth
   lxc.network.link = virbr0
   lxc.network.flags = up
   lxc.network.hwaddr = 00:16:3e:xx:xx:xx

SELinux

SELinux currently prevents lxc to start containers, the issue has been reported at #1227071

A possible workaround is to set SELinux to permissive mode.

Create a container

   # lxc-create -n container1 -t ubuntu -- -r xenial
   # lxc-start -n container1
   # lxc-attach -n container1