How to Install and Use Incus Container in Ubuntu 22.04 LTS

Last updated: February 4, 2024 — Leave a comment

This simple tutorial shows how to install and use Incus container in Ubuntu 22.04 and Ubuntu 20.04 LTS.

Incus is a free open-source system container and virtual machine manager developed by Linux Containers community. It supports images for a large number of Linux distributions.

With it, you can manage your containers and VMs either with a simple command line tool, directly through the REST API or by using third-party tools and integrations.

Incus was started as community fork of Canonical’s LXD. Now, it’s led and maintained by much of the same people that once created LXD.

Step 1: Install Incus

Incus is available in Zabbly repository maintained by the software developer. So far, it supports Ubuntu 22.04, Ubuntu 20.04, Debian 12 and Debian 11.

To install it, first open terminal from system start menu or Gnome activities overview screen. Ubuntu users can simply press Ctrl+Alt+T on keyboard.

1. First, run 2 commands one by one to make sure /etc/apt/keyrings exist, then download & install the key file:

sudo mkdir -p /etc/apt/keyrings
wget -qO - https://pkgs.zabbly.com/key.asc | sudo tee /etc/apt/keyrings/zabbly.asc

For Debian, run sudo apt install wget first if wget command not found.

2. Then, run command to create source file and edit it with nano text editor:

sudo nano /etc/apt/sources.list.d/zabbly-incus-stable.sources

When it opens in the command line text editor, paste following lines:

Enabled: yes
Types: deb
URIs: https://pkgs.zabbly.com/incus/stable
Suites: jammy
Components: main
Architectures: amd64
Signed-By: /etc/apt/keyrings/zabbly.asc

NOTE: You may need to replace jammy (for 22.04) with focal for Ubuntu 20.04, or bookworm/bullseye for Debian 12/11. Also replace amd64 according to dpkg --print-architecture command output.

Finally, press Ctrl+S to save file and Ctrl+X to exit.

3. After properly adding the Zabbly repository and its key file, run the command to refresh system package cache:

sudo apt update

It should output with line says something “Get:x https://pkgs.zabbly.com/incus/stable …”. Finally, you can install the incus container by running command:

sudo apt install incus

For choice, you may also install the incus-ui-canonical package for the web UI support.

Step 2: setup incus

After installed the container, you may run command first to verify its version:

incus version

Then, run command below and answer the questions to configure the daemon:

sudo incus admin init

To allow running incus commands without sudo privilege, you can add current user into incus-admin group:

sudo gpasswd --add $USER incus-admin

Then, run newgrp incus-admin in any terminal to interacts with Incus.

Step 3: Create/Delete containers

To create a container, for example called mycontainer using the Debian 12 image, run command:

incus launch images:debian/12 mycontainer

Then list instances:

incus list

In the case, I can run command to get into bash shell for the Debian 12 container.

incus exec mycontainer bash

To delete the container instance mycontainer, use command:

incus delete mycontainer

Add -f to force deleting running instance, and/or add -i to require user confirmation.

Incus has many other command options, including cluster, config, start, stop, copy and more. You may run incus --help to list them, and run incus <command> --help to get help for each command.

For example, run the command below to tell how to create instances from images:

incus create --help

For more about how to use incus container, see the official Docs.

Uninstall incus container

To uninstall the container installed from Zabbly repository, open terminal and run command:

sudo apt remove --autoremove incus

You may also remove the Zabbly repository by deleting the source and key files via command:

sudo rm /etc/apt/sources.list.d/zabbly-incus-stable.sources /etc/apt/keyrings/zabbly.asc

Finally, refresh your system package cache via sudo apt update.

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

No Comments

Be the first to start the conversation.

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*