Get Started with Incus

A Tiny Cheatsheet with the CRUD

Get Started with Incus

Prerequisites:

Install Incus by following the instructions here:

Initializing Incus:

This has to be done only once, for most use cases, it's right after the install
sudo incus admin init --minimal

This is the same as running the following:

sudo incus admin init

With an Interactive Options list as follows:

Statement Response
Would you like to use clustering? (yes/no) [default=no]: no
Do you want to configure a new storage pool? (yes/no) [default=yes]: yes
Name of the new storage pool [default=default]: incus_stor_local
Where should this storage pool store its data? [default=/var/lib/incus/storage-pools/default]: /var/lib/incus/storage-pools/default
Would you like to create a new local network bridge? (yes/no) [default=yes]: yes
What should the new bridge be called? [default=incusbr0]: incusbr0
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: auto
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: auto
Would you like the server to be available over the network? (yes/no) [default=no]: no
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: yes
Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]: no

Launching a Container

incus launch images:ubuntu/22.04 container0

This command will download a barebones version of Ubuntu-22.04 from the default Incus Image Repository and create a container named container0.

Entering the Newly Created Container

incus exec container0 -- sudo --login --user ubuntu
The Images from the default incus image repository ship with ubuntu as a default user

The Short-Cut Login (Optional)

I get it, sometimes that login command looks way too tedious to type (I'm Lazy), so we can create an alias (a.k.a short-cut) to login easily using:

incus alias add ubuntu 'exec @ARGS@ -- su -l ubuntu'
Use this only once, per incus install

This will now condense the login method to:

incus ubuntu container0
Use only in Host Machine

Exiting A Container

exit
Use only in Container

Stop a Container

incus stop container0

Some times this is not enough , and you would need some elbow grease, so use the --force flag, like this:

incus stop container0 --force
Use only in Host Machine

Restart a Container

incus restart container0
Use only in Host Machine

Some times this is not enough , and you would need some elbow grease, so use the --force flag, like this:

incus restart container0 --force

Copy an Existing Container

incus copy container0 container1
Use only in Host Machine
Make sure the Container being copied is completely stopped