Ceci est une ancienne révision du document !
In my line of work I don't really get any exposure to containers, but the landscape is changing and if you want to stay relevant, you need to know. At first it was a scary prospect, until Daniel from the Full Circle Telegram group gave me a quick introduction to Vagrant. I had seen LXC on the internet, but assumed (incorrectly) that it was just another virtual machine manager. When I wanted to look into LXC, I was told about LXD, which is LXC with bells on.
What is LXD?
LXD is an open source container management extension for Linux Containers (LXC). LXD both improves upon existing LXC features and provides new features and functionality to build and manage Linux containers.
And that is?
Containers are a lightweight virtualisation technology that don't emulate hardware.
Take the fifty cent tour with me.
We can try LXD out online without installing anything at: https://linuxcontainers.org/lxd/try-it/
For those who want to try it at home, the LXD container hypervisors are supported and created by Ubuntu team, so installation is as simple as:
sudo apt install lxd
Our overview: 1. Set up and configure LXD 2. Create our first container 3. Launch a container
Once LXD is installed, there will be a LXD group added to your list of groups. Just add your user to the group to be able to manage containers:
sudo adduser gewgaw lxd
Should the group not be created, add it yourself:
newgrp lxd
Setup
Instead of configuring LXD by hand, it comes with a handy set up: sudo lxd init
You will need to answer the questions on screen to continue. This sets up the storage and networking etc. for you. Once you are done, verify your install with: lxc info
LXD is built on top of LXC so the lxc commands are all valid.
Creation
To create and start containers from images use the launch command: <lxc launch images: >
examples:
lxc launch images:centos/7/amd64 centos-c2
or:
lxc launch images:opensuse/15.0/amd64 opensuse-stable-c8
Can you see the pattern?
Our container is now created. To confirm it was created, we can use the command: lxc list
This will give you the name of your container, the state, the IP address and if it has snapshots. All the commands are self-explanatory, starting with: lxc then what you want to do.
examples: lxc start, lxc stop, lxc info, lxc delete, lxc destroy, lxc create, lxc clone, etc.
You can get a lot more info here: https://help.ubuntu.com/lts/serverguide/lxc.html
LXD is typically added to the Linux kernel. Packaged LXD distributions are available for numerous Linux distributions, including Fedora, Debian, openSUSE, Ubuntu, Alpine Linux, Arch Linux and Gentoo. We can also obtain LXD builds for Windows and OSX.
Launch
When you run 'lxc list', you will get a name in the first column. To start a container, simply type: 'lxc exec' and the name in that first column. For example:
lxc exec centos-c2
adding “–” after the command, allows us to run a command or script in that container. Another example:
lxc exec fedora28-c7 – dnf update
To run a script you need to provide the full path to that script.
To work inside a container, add '– bash' to the end:
lxc exec fedora28-c7 bash
When you are done doing updates or installing software, simply type: exit
That is the quick overview on LXD. There is more to it, but you will pick up everything else very fast once you have this bit under your belt.
Here you can find a list of commands: https://linuxcontainers.org/lxc/manpages/