User:1dent1ty
Linux Containers page draft
Installation
Prerequisites
The only required package is lxc
, however usage of container templates may require additional software, for example bundled lxc-archlinux template require arch-install-scripts and lxc-ubuntu may require debootstrap and dpkg packages.
Host setup
Default root directory for lxc is /var/lib/lxc
, this setting could be overriden via global configuration file. The rest of this page assumes default setting.
To run containers at host startup and shutdown them gracefully use following service file:
$ cat /etc/systemd/system/lxc@.service
[Unit] Description=%I Linux container Wants=network.target After=network.target [Service] Type=simple ExecStart=/usr/bin/lxc-start -n %I ExecStop=/usr/bin/lxc-stop -n %I Restart=on-failure SuccessExitStatus=130 [Install] WantedBy=multi-user.target
Starting container named lxc0
with such service file would be as simple as
# systemctl start lxc@lxc0.service
Container installation
Containers are created with lxc-create
utility. It provides user interface to create and set up container image and optionnaly sets up backing store. The only supported backing stores at the moment are existing filesystem directory (default), LVM logical volume and BTRFS subvolume.
The only required parameter is container name, specified by -n|--name
command line argument, however this command does not do much on itself besides creating container directory and empty container config file.
To install operating system images into containers lxc-create
uses template scripts specified by -t|--template
parameter.
Container setup
Containers configuration resides in config
file located at /var/lib/lxc/<container name>/
directory