Blog

03/06/2019

How to list VM images in LXD (Linux Containers)



I am using LXD (“Linux Container”) a container “hypervisor” on Ubuntu Linux serer. How do I list all available VM images for installation in the LXD image store? Is it possible to list lxd images using lxc command line?

lxd is a system-wide daemon and lxd is a command line client to talk with the lxd daemon. So, you need to use the lxc command to list images in the LXD store. This page shows how to list VM images in LXD using the lxc.

How to list VM images in LXD

The syntax is:
lxc image list images:
Sample outputs:

Fig.01: Listing all VM images

You can use the grep command or more command as follows:
lxc image list images: | more
lxc image list images: | grep -i 'debian'
lxc image list images: | grep -i 'opensuse'

Sample outputs:
Fig.02: Using the grep command to filter out images

You can apply filter as follows to just show alpine Linux vm images:
lxc image list images: 'alpine'
lxc image list images: 'opensuse'

Fig.03: Using filters

You can now create a VM as follows:
lxc launch images:alpine/3.8/amd64 alpine-www
lxc launch images:centos/7/amd64 cenots-db
lxc launch images:opensuse/15.0/amd64 opensuse-15
lxc list

Getting help on image option

Type the following command:
lxc image help
Sample outputs:

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
      --project string   Override the source project
  -q, --quiet            Don't show progress information
  -v, --verbose          Show all information messages
      --version          Print version number
 
Use "lxc image [command] --help" for more information about a command.

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 –project string Override the source project -q, –quiet Don’t show progress information -v, –verbose Show all information messages –version Print version number Use "lxc image [command] –help" for more information about a command.

See lxd documents here for more info.

(adsbygoogle = window.adsbygoogle || []).push({});

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

14/08/2019

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...
14/08/2019

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....
12/08/2019

How to Start and Enable Firewalld on CentOS 7

In this article, we discuss how to start and enable firewalld. It is highly recommended that you have a firewall protecting your server.Pre-Flight CheckThese...