How to list VM images in LXD (Linux Containers)

last updated in Categories , , ,

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
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
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
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:

  Manage images
  In LXD containers are created from images. Those images were themselves
  either generated from an existing container or downloaded from an image
  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).
  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.

Posted by: Vivek Gite

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.

Start the discussion at

Historical Comment Archive

2 comment

  1. I’m running lxc on a Centos7, and have for sometime now been trying to find a way to get ‘lxc’ – does anyone know where I can find the source.

    Still, have a question? Get help on our forum!