OSETC TECH

How to List All VM Images in Linux Container

This post will guide you how to list all avaiable VM images in your LXD Container in Linux. How do I List VM images for installation in the Linux container.

LXD is a next generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead.It’s image based with pre-made images available for a wide number of Linux distributions and is built around a very powerful, yet pretty simple, REST API.

List All VM Images


If you want to install a Virtual Machine in your Linux Container, and you need to list all available VMs images for installation firstly by issuing the following command:

$ lxc image list images:

Outputs:

devops@devops:~$ sudo lxc image list images:
+--------------------------------------+--------------+--------+----------------------------------------------+---------+----------+-------------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
+--------------------------------------+--------------+--------+----------------------------------------------+---------+----------+-------------------------------+
| alpine/3.10 (3 more) | e2a4c6b78f57 | yes | Alpine 3.10 amd64 (20190915_13:00) | x86_64 | 2.39MB | Sep 15, 2019 at 12:00am (UTC) |
+--------------------------------------+--------------+--------+----------------------------------------------+---------+----------+-------------------------------+
| alpine/3.10/arm64 (1 more) | 3c118ef5c995 | yes | Alpine 3.10 arm64 (20190915_13:00) | aarch64 | 2.22MB | Sep 15, 2019 at 12:00am (UTC) |
+--------------------------------------+--------------+--------+----------------------------------------------+---------+----------+-------------------------------+
| alpine/3.10/armhf (1 more) | eceff124b4db | yes | Alpine 3.10 armhf (20190915_13:00) | armv7l | 2.10MB | Sep 15, 2019 at 12:00am (UTC) |
+--------------------------------------+--------------+--------+----------------------------------------------+---------+----------+-------------------------------+
| alpine/3.10/i386 (1 more) | 2a93ca178689 | yes | Alpine 3.10 i386 (20190915_13:00) | i686 | 2.40MB | Sep 15, 2019 at 12:00am (UTC) |
+--------------------------------------+--------------+--------+----------------------------------------------+---------+----------+-------------------------------+
| alpine/3.10/ppc64el (1 more) | dc225fe46fd5 | yes | Alpine 3.10 ppc64el (20190915_13:00) | ppc64le | 2.29MB | Sep 15, 2019 at 12:00am (UTC) |
+--------------------------------------+--------------+--------+----------------------------------------------+---------+----------+-------------------------------+
| alpine/3.10/s390x (1 more) | 77a8fd49aa55 | yes | Alpine 3.10 s390x (20190915_13:00) | s390x | 2.09MB | Sep 15, 2019 at 12:00am (UTC) |
+--------------------------------------+--------------+--------+----------------------------------------------+---------+----------+-------------------------------+
......

Once you get the Image ALIAS that you want to install in your LXD, and you can use the following command to create a new VM, type:

$ lxc lauch images: centos/7/amd64 mycentos

If you get more information about lxc image command, and you can get the help information with the following command:

$ lxc image help

outputs:

devops@devops:~$ lxc image help
Description:
Manage images

In LXD containers are created from images. Those images were themselves
either generated from an existing container or downloaded from an image
server.

When using remote images, LXD will automatically cache images for you
and remove them upon expiration.

The image unique identifier is the hash (sha-256) of its representation
as a compressed tarball (or for split images, the concatenation of the
metadata and rootfs tarballs).

Images can be referenced by their full hash, shortest unique partial
hash or alias name (if one is set).

Usage:
lxc image [command]

Available Commands:
alias Manage image aliases
copy Copy images between servers
delete Delete images
edit Edit image properties
export Export and download images
import Import images into the image store
info Show useful information about images
list List images
refresh Refresh images
show Show image properties

Global Flags:
--debug Show all debug messages
--force-local Force using the local unix socket
-h, --help Print help
-v, --verbose Show all information messages
--version Print version number

Use "lxc image [command] --help" for more information about a command.

If you want to list all VMs, you can use the following commands:

$ lxc list

Outputs:

devops@devops:~$ lxc list
+-------------------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-------------------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| container2 | RUNNING | 10.128.138.192 (eth0) | fd42:841b:d3e7:7c96:216:3eff:fe2d:bbd2 (eth0) | PERSISTENT | 0 |
+-------------------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| container3 | RUNNING | 10.128.138.83 (eth0) | fd42:841b:d3e7:7c96:216:3eff:fea8:b20e (eth0) | PERSISTENT | 0 |
+-------------------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| myalpineContainer | RUNNING | 10.128.138.16 (eth0) | fd42:841b:d3e7:7c96:216:3eff:fe5d:887c (eth0) | PERSISTENT | 0 |
+-------------------+---------+-----------------------+-----------------------------------------------+------------+-----------+

Conclusion


You should know that how to list all available VM images in LXD container in a CentOS or RHEL or Ubuntu Linux server.