Tech Recipe Book
My Services
  • Book
    • About the author
    • Architect
      • Algorithms
        • DB index algorithms
          • How does database indexing work
        • Neural network optimization
          • Neural Network Optimization
        • Route search
          • Road network in a database to build a route
          • Traveling Salesman Problem (TSP)
      • Architecture Frameworks
        • DODAF
        • TOGAF
        • Enterprise Architecture (EA) Tools Reviews 2023 | Gartner
      • Zero Trust
      • Billing
        • SHM billing system
      • Bots
        • Discord
        • Telegram
          • Chat GPT Telegram bot
          • Получаем статистику Telegram-канала при помощи api и python или свой tgstat с регистрацией и смс
          • Как хостить телеграм-бота (и другие скрипты на Python) на Repl.it бесплатно 24/7
          • Создание Telegram бота на PHP #1: основные понятия для работы с API
          • Создание Telegram бота на PHP #2: создание первого бота для Telegram
          • Создание Telegram бота на PHP #3: примеры отправки сообщений с кнопками в Telegram
          • Создание Telegram бота на PHP #4: отправка файлов и изображений в Telegram
          • Создание Telegram бота на PHP #5: работа с хуками
      • Business intelligence
      • Cloud Storage
        • Ceph
        • Virtual Distributed File System
      • Cryptography
        • Open Source PKI Software
        • OpenPGP
          • Email Encryption
          • Kleopatra
          • Miscellaneous Tools
          • Server side applications
      • Message broker
        • Kafka
          • Kafka UI-tools
          • Kafka streams ksqlDb
        • RabbitMQ
      • DB
        • MySQL
          • Auto sharding
          • MariaDB Zabbix monitoring
          • MySQL and MariaDB replication with Zabbix monitoring
        • Postgres
          • HA PostgreSQL with Patroni, Haproxy, Keepalived
          • Mass parallel requests - Greenplum
          • PostgreSQL cluster for development and testing
        • Vitess - Scalable. Reliable. MySQL-compatible. Cloud-native. Database.
      • Identity and Access Management (IDM)
        • FreeIPA - Identity, Policy, Audit
        • FreeIPA as an Enterprise solution
        • Keycloak
          • Keycloak HA cluster
        • Open Identity Platform
        • SSO
          • Keycloak for Java app
          • OpenAM
          • OpenIG
      • Firewall
        • nftables
      • Infrastructure As a Code
        • Ansible
        • IaC Packer Ansible Teraform
        • Installing Jenkins using terraform in Kubernetes in Yandex Cloud with letsencypt
        • Teraform Crosplan Pulumi
        • Yandex IaC solutions
      • Kubernetes
        • Installation
          • Install Kubernetes cluster
          • Deploying a Kubespray cluster to OpenStack using Terraform
          • Kube deploy in Yandex cloud
        • Frameworks
          • Deckhouse
            • LDAP authentification
            • On premise Install
            • Yandex Cloud Install
          • K3S
          • OpenShift OKD
          • RKE2
          • Rancher
            • Rancher Install
        • Auth
          • Keycloak in k8s
          • LDAP
        • GUI management Lens
        • Monitoring
          • Monitoring with Falco
          • Network monitoring
          • Nginx ingress
          • Prometheus Graphana for sample Nodejs app
          • Rsource monitoring Avito
        • Exposing services
          • Exposing Kubernetes Services
          • Cilium BGP
        • CNCF
        • Helm
          • Repositories
            • Artifact Hub | official
            • Bitnami | vmware
          • Awesome helm charts and resources
          • Essential Services for Modern Organizations
          • Security and Compliance
          • Additional charts
        • Isolation
          • vcluster - Virtual Kubernetes Clusters
          • Kiosk
          • KubeArmor
          • Control Plane Hardening
          • Hierarchical namespaces
        • Security Center
          • Minesweeper
          • NeuVector by SUSE
          • SOAR in Kubernetes
          • Security Сenter for Kubernetes
        • Terraform CI security
          • Terraform plan analysis with Checkov and Bridgecrew
          • Yandex Terraform scan
        • Vulnerability management
          • Aqua
          • Sysdig
          • Kyverno
          • GitLab
          • NeuVector by SUSE
        • Image scanning
          • Snyk
          • Sysdig
          • Harbor
          • Trivy
        • Signature verification
          • Sigstore
        • Control plane security
          • Gatekeeper
            • Applying OPA Gatekeeper
          • Kyverno
            • Policy as a code. Kyverno
        • Runtime Security
          • Osquery
          • Falco
          • ClamAV
        • Network security
          • Cilium
          • Control Plane Hardening (API restriction)
          • Network policy recipes
          • Service mesh
            • Istio HA, LoadBalance, Rate limit
          • mTLS Autocert
        • Honeypot
          • Building honeypot using vcluster and Falco
        • Backup
          • Kasten K10
        • Secrets
          • Vault CSI Driver
      • Load Balance
        • Nginx
        • HAProxy
          • Proxy methods
          • HAProxy for RDP
          • Payment gateway A/B test with HAProxy
          • HAPRoxy for Percona or Galera
      • Monitoring
        • Zabbix
          • Apache Zabbix
          • Disc Quota
          • Nginx Zabbix
          • SSL certificates Zabix
          • Zabbix notifications
        • Nagios
          • Datacenter monitoring
        • Prometheus and Grafana
      • Windows
        • Sysmon enhanced Windows audit
        • Sysmon to Block Unwanted File
      • Linux
        • Rsync
        • Debian based
          • Apt-Cacher NG
          • Unattended Upgrades in Debian / Ubuntu
        • RedHat basede
          • RPM Server
        • Logs analysis
        • Build armhf qemu
      • NGFW
      • CI/CD
        • DevSecOps
          • DAST
            • Burp
              • Dastardly
            • StackHawk
            • ZAP and GitHub Actions
          • SAST
            • Checkmarx
            • OSV by Google
            • Snyk
            • SonarQube
        • GitLab Runner in Yandex Cloud
        • Dynamic Gitlab Runners in Yandex Cloud
        • GitLab runner in Kubernetes with Werf
        • Kubernetes deploy strategies
        • Kubernetes highload deploy. part 1
        • Kubernetes highload deploy. part 2
        • Kubernetes Argo Rollouts
        • Jenkins in Kubernetes
        • Ansible Semaphore
        • Image storage, scaning and signing
        • Install WireGuard with Gitlab and Terraform
        • CI/CD example fror small web app
        • Threat matrix for CI CD Pipeline
      • SIEM / SOC
        • Datadog
        • Splunk
          • Splunk — general description
        • MaxPatrol
          • MaxPatrol 8 and RedCheck Enterprise
        • QRadar IBM
        • Cloud Native Security Platform (CNAPP) - Aqua
        • OSSIM | AT&T
          • AlienVault (OSSIM) install
        • Wazuh
        • EDR
          • Cortex XDR | Palo Alto Networks
          • Cynet
          • FortiEDR | Fortinet
          • Elastic
        • Elastic
          • Install Elasticsearch, Logstash, and Kibana (Elastic Stack) on Ubuntu 22.04
          • Setting Up Elastic 8 with Kibana, Fleet, Endpoint Security, and Windows Log Collection
        • Threat Intelligence
          • MISP
          • msticpy Microsoft
          • X-Force | IBM
          • Elastic
      • VPN
        • Full-Mesh VPN fastd, tinc, VpnCloud
        • Wireguard
          • WireGuard for Internet access
          • WireGuard on MikroTik and Keenetic
          • WireGuard site to site
        • SoftEther VPN Project
        • Cisco AnyConnect client
        • OpenConnect
        • SSTP python server
      • OS hardening
        • CIS Benchmarks
      • Cloud Providers
      • OpenNebula
        • OpenNebula Edge Cloud - Open Source Cloud & Edge Computing
        • Discover OpenNebula – Open Source Cloud & Edge Computing Platform
        • OpenNebula Multi-Cloud
        • Kubernetes on OpenNebula
        • The Open Source Alternative to Nutanix
        • The Simple Alternative to OpenStack
        • OpenNebula Partner Ecosystem
      • OpenStack
        • Install manual
        • Install with DevStack
      • VM
        • Create a VHD file from a Linux disk
        • Backup / Migration
          • Coriolis
          • Proxmox Backup Server
        • oVirt
        • VMware vCenter
        • Proxmox
      • Docker
        • Container optimization
        • Ubuntu RDP container
      • LXC
        • LXD on Ubuntu 18.04
        • Install, Create and Manage LXC in Ubuntu/Debian
    • Big Data
      • OLAP data qubes
      • Storage and autoscale in Lerua
    • Machine Learning
      • Yandex YaLM 100B. GPT model
      • Kaggle Community Datasts Models
      • AI in video production
      • Image search
      • Chat bots
        • You.com
        • Chat GPT
          • Implementing GPT in NumPy
        • Jailbreak Chat
      • Coding plugins CodeWhisperer
    • Malware
      • Isiaon/Pitraix: Modern Cross-Platform Peer-to-Peer Botnet over TOR
      • theZoo A repository of LIVE malwares
    • Pentest
      • Red Team
        • MITRE ATT&CK matrix
        • C2 Frameworks
          • Brute Ratel C4
          • Cobalt Strike
          • Covenant
          • Havoc Framework
          • Merlin
          • Metasploit
          • Sillenttrinity
          • Sliver
        • Manage and report
          • Dradis Framework
          • Hexway
        • Underground
      • Social engineering
        • Social Engineer Toolkit setoolkit
      • OSINT
        • OSINT for comapny
        • Instagram fishing
      • Forensics
        • Forensics tools
      • Pentesting Methodology
      • Web
      • CI/CD Methodology
      • Cloud Methodology
        • Hacking The Cloud
      • Kubernetes Pentesting
      • Android
        • SSL Unpinning for Android applications
      • iOS
        • SSL unpinning iOS and macOS applications
      • HackBar tool
      • CyberChef Tools
      • Python virtualenv
      • IppSec - YouTube
      • Hacktricks.xyz
    • Compliance
      • 152 ФЗ. Personal data
      • PCI DSS and ГОСТ Р 57580.1-2017
      • Cloud compliance
      • ГОСТ Р 57580.1-2017 для Kubernetes
      • Kubernets as DevSecOps and NIST compliance
      • NIST SP 800-61 cyberincidece control
      • CIS Kubernetes Benchmark v1.6 - RKE2 v1.20
      • CIS Kubernetes Benchmark v1.23 - RKE2
      • Requirements for Russian Banks
      • Tools
        • Chef InSpec
        • Elastic SIEM
    • Asset management
      • CMDBuild
    • Project management
    • Incident management SRE
    • Risk management
      • IT risk management
      • BSI-Standard 200-3
    • Web Dev
      • Cookie security
      • OWASP Top 10 2021
      • Docker nginx php mysql
      • Docker tor hiddenservice nginx
      • Docker Compose wp nginx php mariadb
      • Dependency Checking
        • Nexus Analyzer
        • OWASP dependency-check
      • Yii skeeks cms
      • YiiStudio
    • Art
      • GTK Themes
      • Themes for Xfce Desktop
      • XFCE / Xubuntu Windows 95
      • Moscow events
      • Photo goods
      • Russian style gifts
    • Cryptocurrency
      • News
      • Arbitrage
      • Stocks
      • Exchange aggregators
      • Where to use
      • Prepaid cards
        • BitFree
        • Pyypl Your Money at Your Fingertips
    • IT magazines
      • WIKI and Writeups tools
        • BookStack
        • GitBook
        • MkDocs
        • Wiki.js
        • DokuWiki
    • Languages
    • Learning
      • (ISC)2
        • CISSP
      • Offensive Security
        • OSCP
        • OSEP
        • OSED
      • DevSecOps
        • Certified DevSecOps Professional (CDP)
        • Certified DevSecOps Expert (CDE)
      • Web Security Academy: PortSwigger
    • Relocation
      • London experience
      • IT visas in 2022
      • Remote work
      • Running business in UAE
    • Freenet
      • Independent online services: the philosophy of a free Internet
      • Tor Project Anonymity Online
      • I2P Anonymous Network
    • Services
      • SMS Registration
        • Registering ChatGPT in Russia
      • Local and regional eSIMs for travellers - Airalo
      • Digital busines cards
      • No KYC services and exchanges
Powered by GitBook
On this page
  • Step 1: Install LXD on Ubuntu
  • Step 2: Initializing LXD Service
  • Step 3: Creating LXD Containers in Ubuntu
  • Step 4: Managing LXD Containers in Ubuntu

Was this helpful?

  1. Book
  2. Architect
  3. LXC

Install, Create and Manage LXC in Ubuntu/Debian

Last updated 1 year ago

Was this helpful?

Over the last decade, the open-source community has seen a steady shift to containerization as the preferred way of deploying applications thanks to the numerous benefits it offers such as portability, flexibility, increased security, and easier management of applications. Popular containerization technologies include , Podman, and LXD.

Written in Go language, (pronounced as Lekseed) is described as the next generation system container and virtual machine manager that allows you to manage your containers and virtual machines from the command line, or by leveraging a REST API or other third party tools. LXD is an open-source project and is an extension of LXC (Linux Containers) which is OS-level virtualization technology.

LXC came into the picture around 2008, and LXD was launched 7 years later in 2015 with the same building blocks as LXC. LXD came to make containers more user-friendly and easy to manage.

Being an extension of LXC, LXD provides advanced features such as snapshots and live migration. It also provides a daemon that lets you easily manage containers and virtual machines. It is not intended to supplant LXC, rather, it is aimed at improving the usability and handling of LXC-based containers

In this guide, we will demonstrate how you can create and manage LXC containers using LXD on Debian/Ubuntu.

Step 1: Install LXD on Ubuntu

The first step is to install LXD. There are two ways of doing this, you can install from Ubuntu’s repository using the or you can use .

Using APT, first update the system:

$ sudo apt update

Then install the LXD system container hypervisor as follows.

$ sudo apt install lxd

Install LXD in Ubuntu

Using snap, you can install the latest version of LXD.

$ sudo snap install lxd

In addition, you can install the latest LTS release which is LXD 4.0 as follows:

$ sudo snap install lxd --channel=4.0/stable

You can verify the version of LXD installed as shown:

$ lxd --version

Check LXD Version

If you used to snap, you can verify that the LXD snap package was installed as shown:

$ snap list

List LXD Snap Package

Step 2: Initializing LXD Service

To initialize or start the LXD container hypervisor, run the command:

$ sudo lxd init

The command presents you with a set of questions on how to configure LXD. The defaults work just fine, however, you are at liberty to specify your own settings as per your requirements.

In this example, we have created a storage pool called tecmint_pool with the ZFS file system and volume manager. For the rest of the questions, we have chosen to go with the default options. An easy way to accept the default selection is to press the ENTER button on your keyboard.

Initializing LXD Service

Confirm the information provided by running the command:

$ sudo lxc profile show default

Confirm LXD Profile

You can further narrow it down to the storage pool created. The commands below display details of the current storage pools.

$ sudo lxc storage list
$ sudo lxc storage show tecmint_pool

List LXD Storage Pools

You can also display information about the network interface in use by LXD, in this case, lxdbr0, which is the default selection.

$ sudo lxc network show lxdbr0

List LXD Network Configuration

Step 3: Creating LXD Containers in Ubuntu

Now, let’s switch gears and create Linux containers. You can list all the prebuilt containers that are available for download using the command:

$ sudo lxc image list images:

This populates a huge list of all the containers in various operating systems such as Ubuntu, CentOS, Debian, and AlmaLinux, to mention a few.

You can narrow it down to a specific distribution as follows:

$ sudo lxc image list images: | grep -i centos
$ sudo lxc image list images: | grep -i debian

In this example, we are listing the available containers.

$ sudo lxc image list images: | grep -i ubuntu

Now, we are going to create our first container. The syntax for creating a container is as follows:

$ sudo lxc launch images:{distro}/{version}/{arch} {container-name}

Now we are going to create two containers from Ubuntu 20 and Debian 10 respectively:

$ sudo lxc launch images:ubuntu/focal tecmint-con1
$ sudo lxc launch images:debian/10 tecmint-con2

In the above examples, we have created two containers: tecmint-con1 and tecmint-con2.

To list the containers created, run the command:

$ sudo lxc list

From the output, we can see our two containers listed.

To gain shell access to a LXC container run the command:

$ sudo lxc exec tecmint-con1 bash

Once you have gained shell access, notice that the prompt changes to indicate that you are running as the root user.

Access LXC Container Shell

To exit the container, run the command:

$ exit

Step 4: Managing LXD Containers in Ubuntu

Now, let’s check out some of the commands you can use to manage LXD containers.

To list all the running containers, run the command:

$ sudo lxc list

To display detailed information about an LXC container, use the syntax:

$ sudo lxc info container-name

This will provide you with information such as the container’s name, architecture, creation date, status network interfaces, bandwidth, CPU, memory, and disk usage to mention a few metrics.

Get LXC Container Info

To stop an LXC container, use the syntax:

$ sudo lxc stop container-name

For example, to stop container tecmint-con1, execute the command:

$ sudo lxc stop  tecmint-con1

Again, list the containers to confirm that the container has been stopped.

$ sudo lxc list

Alternatively, you can list either running or stopped containers as follows:

$ sudo lxc list | grep -i STOPPED
$ sudo lxc list | grep -i RUNNING

To start an LXC container, use the syntax:

$ sudo lxc start container-name

For example, to start container tecmint-con1 run the command:

$ sudo lxc start tecmint-con1

You can start or stop containers bypassing them in one command separated by a space using the following syntax:

$ sudo lxc stop container1 container2
$ sudo lxc start container1 container2

For example, to stop all containers, run:

$ sudo lxc stop tecmint-con1 tecmint-con2

To restart an LXC container, use the syntax:

$ sudo lxc restart container-name

For example, to restart container tecmint-con1 run the command:

$ sudo lxc restart tecmint-con1

Alternatively, you can pass multiple containers in a single command:

$ sudo lxc start container1 container2

For example, to restart all containers, run:

$ sudo lxc restart tecmint-con1 tecmint-con2

To delete an LXC container, first, stop it, then delete it. For example, to delete container tecmint-con2, run the command:

$ sudo lxc stop tecmint-con2
$ sudo lxc delete tecmint-con2

This guide has provided you with a solid foundation about LXD containers and how you can launch, create and manage containers. It’s our hope that you can now comfortably launch and manage your containers without much difficulty.

https://www.tecmint.com/install-lxc-ubuntu-debian/
Docker
LXD
APT package manager
snap