LXD is free software developed by Canonical to simplify the handling of software containers like a VM hypervisor. It is a software overlay of LXC. It is part of the overall LinuX Containers container management project. We will see its installation and the basic commands allowing to manage the containers.
We always start with an updated system:
sudo Apt-update ; sudo apt-upgrade
Now we install the lxd package then we initialize it
sudo apt install lxd lxd init
We have to answer to the differents questions. For simple use, the default responses are sufficient.
TheWould you like to use LXD clustering? (yes/no) [default=no]: Do you want to configure a new storage pool? (yes/no) [default=yes]: Name of the new storage pool [default=default]: pool Name of the storage backend to use (btrfs, dir, lvm) [default=btrfs]: Create a new BTRFS pool? (yes/no) [default=yes]: Would you like to use an existing block device? (yes/no) [default=no]: Size in GB of the new loop device (1GB minimum) [default=15GB]: Would you like to connect to a MAAS server? (yes/no) [default=no]: Would you like to create a new local network bridge? (yes/no) [default=yes]: What should the new bridge be called? [default=lxdbr0]: What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: Would you like LXD to be available over the network? (yes/no) [default=no]: yes Address to bind LXD to (not including port) [default=all]: Port to bind LXD to [default=8443]: Trust password for new clients: Again: Would you like stale cached images to be updated automatically? (yes/no) [default=yes] Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:
And voila. We have a container system ready to serve.
We are going to start by downloading anDebian image and create a container with the same command :
lxc launch images:debian/buster containerDebian
Now we can show the new container with the command:
As well as the downloaded image that we can reuse at to create other containers now :
Working with container
It is possible to execute tasks directly:
lxc exec DebianContainer -- apt get update
Or to “enter” inside the container then execute commands like in any Linux system :
lxc exec DebianContainer bash