
{"id":45455,"date":"2024-02-04T13:10:34","date_gmt":"2024-02-04T13:10:34","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=45455"},"modified":"2024-02-04T13:10:34","modified_gmt":"2024-02-04T13:10:34","slug":"use-incus-container-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/02\/use-incus-container-ubuntu\/","title":{"rendered":"How to Install and Use Incus Container in Ubuntu 22.04 LTS"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-logo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-45456\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-logo-700x700.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This simple tutorial shows how to install and use Incus container in Ubuntu 22.04 and Ubuntu 20.04 LTS.<\/p>\n<p>Incus is a free open-source system container and virtual machine manager developed by Linux Containers community. It supports images for a <a href=\"https:\/\/images.linuxcontainers.org\/\" target=\"_blank\" rel=\"noopener\">large number of Linux distributions<\/a>.<\/p>\n<p>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.<\/p>\n<p>Incus was started as community fork of Canonical&#8217;s LXD. Now, it&#8217;s led and maintained by much of the same people that once created LXD.<\/p>\n<h3>Step 1: Install Incus<\/h3>\n<p>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.<\/p>\n<p>To install it, first open terminal from system start menu or Gnome activities overview screen. Ubuntu users can simply press <code>Ctrl+Alt+T<\/code> on keyboard.<\/p>\n<p><!--more--><\/p>\n<p><b>1.<\/b> First, run 2 commands one by one to make sure <code>\/etc\/apt\/keyrings<\/code> exist, then download &amp; install the key file:<\/p>\n<pre>sudo mkdir -p \/etc\/apt\/keyrings<\/pre>\n<pre>wget -qO - https:\/\/pkgs.zabbly.com\/key.asc | sudo tee \/etc\/apt\/keyrings\/zabbly.asc<\/pre>\n<p><i>For Debian, run <code>sudo apt install wget<\/code> first if wget command not found.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/zabbly-key.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45457\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/zabbly-key-700x454.webp\" alt=\"\" width=\"610\" height=\"396\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/zabbly-key-700x454.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/zabbly-key-300x195.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/zabbly-key-768x498.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/zabbly-key.webp 822w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>2.<\/b> Then, run command to create source file and edit it with nano text editor:<\/p>\n<pre>sudo nano \/etc\/apt\/sources.list.d\/zabbly-incus-stable.sources<\/pre>\n<p>When it opens in the command line text editor, paste following lines:<\/p>\n<pre>Enabled: yes\r\nTypes: deb\r\nURIs: https:\/\/pkgs.zabbly.com\/incus\/stable\r\nSuites: <b>jammy<\/b>\r\nComponents: main\r\nArchitectures: <b>amd64<\/b>\r\nSigned-By: \/etc\/apt\/keyrings\/zabbly.asc<\/pre>\n<p><b>NOTE: You may need to replace <b>jammy<\/b> (for 22.04) with <b>focal<\/b> for Ubuntu 20.04, or <b>bookworm<\/b>\/<b>bullseye<\/b> for Debian 12\/11. Also replace <b>amd64<\/b> according to <code>dpkg --print-architecture<\/code> command output.<\/b><\/p>\n<p>Finally, press Ctrl+S to save file and Ctrl+X to exit.<br \/>\n<a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-repo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45458\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-repo-700x454.webp\" alt=\"\" width=\"610\" height=\"396\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-repo-700x454.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-repo-300x195.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-repo-768x498.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-repo.webp 822w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>3.<\/b> After properly adding the Zabbly repository and its key file, run the command to refresh system package cache:<\/p>\n<pre>sudo apt update<\/pre>\n<p>It should output with line says something &#8220;Get:x https:\/\/pkgs.zabbly.com\/incus\/stable &#8230;&#8221;. Finally, you can install the incus container by running command:<\/p>\n<pre>sudo apt install incus<\/pre>\n<p><i>For choice, you may also install the <code>incus-ui-canonical<\/code> package for the web UI support.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-incus.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45459\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-incus-700x558.webp\" alt=\"\" width=\"610\" height=\"486\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-incus-700x558.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-incus-300x239.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-incus-768x612.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-incus.webp 804w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Step 2: setup incus<\/h3>\n<p>After installed the container, you may run command first to verify its version:<\/p>\n<pre>incus version<\/pre>\n<p>Then, run command below and answer the questions to configure the daemon:<\/p>\n<pre>sudo incus admin init<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-setup.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45460\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-setup-700x454.webp\" alt=\"\" width=\"610\" height=\"396\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-setup-700x454.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-setup-300x195.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-setup-768x498.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-setup.webp 822w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>To allow running incus commands without sudo privilege, you can add current user into incus-admin group:<\/p>\n<pre>sudo gpasswd --add $USER incus-admin<\/pre>\n<p>Then, run <code>newgrp incus-admin<\/code> in any terminal to interacts with Incus.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-incus-admin.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45461\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-incus-admin-700x276.webp\" alt=\"\" width=\"610\" height=\"241\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-incus-admin-700x276.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-incus-admin-300x118.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-incus-admin-768x303.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/add-incus-admin.webp 822w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Step 3: Create\/Delete containers<\/h3>\n<p>To create a container, for example called <code>mycontainer<\/code> using the Debian 12 image, run command:<\/p>\n<pre>incus launch images:debian\/12 mycontainer<\/pre>\n<p>Then list instances:<\/p>\n<pre>incus list<\/pre>\n<p>In the case, I can run command to get into bash shell for the Debian 12 container.<\/p>\n<pre>incus exec mycontainer bash<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-firstcontainer.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45463\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-firstcontainer-700x500.webp\" alt=\"\" width=\"610\" height=\"436\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-firstcontainer-700x500.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-firstcontainer-300x214.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-firstcontainer-768x548.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-firstcontainer.webp 948w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>To delete the container instance <code>mycontainer<\/code>, use command:<\/p>\n<pre>incus delete mycontainer<\/pre>\n<p><i>Add <code>-f<\/code> to force deleting running instance, and\/or add <code>-i<\/code> to require user confirmation.<\/i><\/p>\n<p>Incus has many other command options, including <code>cluster<\/code>, <code>config<\/code>, <code>start<\/code>, <code>stop<\/code>, <code>copy<\/code> and more. You may run <code>incus --help<\/code> to list them, and run <code>incus &lt;command&gt; --help<\/code> to get help for each command.<\/p>\n<p>For example, run the command below to tell how to create instances from images:<\/p>\n<pre>incus create --help<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-help.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45462\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-help-700x474.webp\" alt=\"\" width=\"610\" height=\"413\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-help-700x474.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-help-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-help-768x520.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/incus-help.webp 894w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>For more about how to use incus container, see the <a href=\"https:\/\/linuxcontainers.org\/incus\/docs\/main\/\" target=\"_blank\" rel=\"noopener\">official Docs<\/a>.<\/p>\n<h3>Uninstall incus container<\/h3>\n<p>To uninstall the container installed from Zabbly repository, open terminal and run command:<\/p>\n<pre>sudo apt remove --autoremove incus<\/pre>\n<p>You may also remove the Zabbly repository by deleting the source and key files via command:<\/p>\n<pre>sudo rm \/etc\/apt\/sources.list.d\/zabbly-incus-stable.sources \/etc\/apt\/keyrings\/zabbly.asc<\/pre>\n<p>Finally, refresh your system package cache via <code>sudo apt update<\/code>.<\/p>","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":45456,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2144,2145],"class_list":["post-45455","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-container","tag-incus"],"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/45455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=45455"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/45455\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/45456"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=45455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=45455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=45455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}