Difference between revisions of "LXD"

From ArchWiki
Jump to navigation Jump to search
(Created LXD page to go with the lxd AUR package, since LXD requires some user action to set up.)
m (A sudo sneaked in.)
Line 22: Line 22:
By default the LXD daemon allows users in the {{ic|lxd}} group access, so add your user to the group:
By default the LXD daemon allows users in the {{ic|lxd}} group access, so add your user to the group:
  $ sudo usermod -a -G lxd <user>
  $ usermod -a -G lxd <user>
=== LXD Networking ===
=== LXD Networking ===

Revision as of 12:45, 1 March 2016

LXD is a container "hypervisor" and a new user experience for Linux Containers.


Required software

Install lxc from the official repositories and lxdAUR from AUR.

Verify that the running kernel is properly configured to run a container:

$ lxc-checkconfig

Due to security concerns, the default Arch kernel does NOT ship with the ability to run containers as an unprivileged user. LXD however needs this ability to run. You can either build a kernel yourself that has CONFIG_USER_NS enabled, or use linux-user-ns-enabledAUR from the AUR.

Sub{u,g}id configuration

You'll need sub{u,g}ids for root, so that LXD can create the unprivileged containers:

$ echo "root:1000000:65536" | sudo tee -a /etc/subuid /etc/subgid

Accessing LXD as a unprivileged user

By default the LXD daemon allows users in the lxd group access, so add your user to the group:

$ usermod -a -G lxd <user>

LXD Networking

LXD uses LXC's networking capabilities. By default it connects containers to the lxcbr0 network device. Refer to the LXC documentation on network configuration to set up a bridge for your containers.

If you want to use a different interface than lxcbr0 edit the default using the lxc command line tool:

$ lxc profile edit default

An editor will open with a config file that by default contains:

name: default
config: {}
    name: eth0
    nictype: bridged
    parent: lxcbr0
    type: nic

You can set the parent parameter to whichever bridge you want LXD to attach the containers to by default.

Basic usage

First steps

LXD has two parts, the daemon (the lxd binary), and the client (the lxc binary). Now that the daemon is all configured and running, you can import an image:

$ lxd-images import ubuntu --alias ubuntu

With that image imported into LXD, you can now start containers:

$ lxc launch ubuntu

Alternatively, you can also use a remote LXD host as a source of images. Those will be automatically cached for you for up at container startup time:

$ remote add images images.linuxcontainers.org
$ launch images:centos/7/amd64 centos

See also