As LXD evolves quite rapidly, we recommend Ubuntu users use our PPA:
add-apt-repository ppa:ubuntu-lxc/lxd-stable apt-get update apt-get dist-upgrade apt-get install lxd
The package creates a new “lxd” group which contains all users allowed to talk to lxd over the local unix socket. All members of the “admin” and “sudoers” groups are automatically added. If your user isn’t a member of one of these groups, you’ll need to manually add your user to the “lxd” group.
Because group membership is only applied at login, you then either need to close and re-open your user session or use the “newgrp lxd” command in the shell you’re going to interact with lxd from.
LXD is available for Ubuntu Core as a Snap package in the store. You can install it with:
sudo snappy install lxd.stgraber
After that, LXD can be interacted with through the “lxc” and “lxd-images” commands.
There are currently packages for multiple distributions including Gentoo and, of course, Ubuntu. Users of other distributions might find it in their package manager too.
If it is not there yet please download and build LXD from git or use our latest release tarball.
LXD is image based. Containers must be created from an image and so the image store must get some images before you can do much with LXD.
There are three ways to feed that image store:
Using a remote image server is as simple as adding it as a remote and just using it:
lxc remote add images images.linuxcontainers.org lxc launch images:centos/7/amd64 centos
An image list can be obtained with:
lxc image list images:
lxd-images is a python script which knows about non-LXD image servers
and can pull and import images for you.
It currently supports two sources:
Importing a new image can be done with:
lxd-images import busybox --alias busybox lxd-images import ubuntu --alias ubuntu
And then simply using the image to start containers:
lxc launch busybox my-busybox lxc launch ubuntu my-ubuntu
If you already have a lxd-compatible image file, you can import it with:
lxc image import \<file\> --alias my-alias
And then start a container using:
lxc launch my-alias my-container
See the image specification for more details.
Assuming that you imported an Ubuntu cloud image using the “ubuntu” alias, you can create your first container with:
lxc launch ubuntu first
That will create and start a new ubuntu container as can be confirmed with:
Your container here is called “first”. You also could let LXD give it a random name by just calling “lxc launch ubuntu” without a name.
Now that your container is running, you can get a shell inside it with:
lxc exec first -- /bin/bash
Or just run a command directly:
lxc exec first -- apt-get update
To pull a file from the container, use:
lxc file pull first/etc/hosts .
To push one, use:
lxc file push hosts first/tmp/
To stop the container, simply do:
lxc stop first
And to remove it entirely:
lxc delete first
The “lxc” command line tool can talk to multiple LXD servers. It defaults to talking to the local one using a local UNIX socket.
Remote operations require the following two commands having been run on the remote server:
lxc config set core.https_address [::] lxc config set core.trust_password some-password
The first tells LXD to bind all addresses on port 8443. The latter sets a trust password to be used when contacting that server.
Now to talk to that remote LXD, you can simply add it with:
lxc remote add host-a <ip address or DNS>
This will prompt you to confirm the remote server fingerprint and then ask you for the password.
And after that, use all the same command as above but prefixing the container and images name with the remote host like:
lxc exec host-a:first -- apt-get update
— from linuxcontainers.org
Updated 5 October 2015
The leading platform for scale-out computing, Ubuntu Server delivers the best value scale-out performance available.
“All my centurions develop using snaps.” Julius Caesar By and large, software development can be an enjoyable process. Until you hit the first error, that is. At that point, you want to get past the stumbling blocks as quickly as possible…
Introduction On supported Chromebook, starting with Chrome OS 69, a new feature called Linux Apps was introduced. This allows Chrome OS users, on supported to install normal Linux applications from the Debian repository and have them…
The appeal of Kubernetes is universal. Application development, operations and infrastructure teams recognise diverse reasons for its immediate utility and growing potential — a testament of Kubernetes’ empathetic design. Web apps,…