Images in OpenStack are what powers instances. This guide will explain how to use images that are already uploaded into Glance, the OpenStack service responsible for images and how to upload your own.

An image is a file that contains a bootable operating system. Many different cloud image sources are available for download from major operating system providers like CentOS, Ubuntu, and Debian to name a few. You can also make your own images from scratch or create them from volumes or running instances. Snapshots of instances can be created which can serve both as a backup and also a template for other instances.

It is possible to create your own images however this process is outside the scope of this guide. For more information on how to do this, see the documentation from OpenStack.


List and upload images

This section will cover how to view and upload images into OpenStack. Either Horizon or the command line using OpenStackClient can be used.

Using Horizon

In Horizon, the images can be found on the left within the Compute tab under Images. From this interface, you could launch an instance using one of the images and also upload your own.

List images

Images in Horizon:

Upload and create images

In the same Horizon interface, you can upload an image, make your own or make an image snapshot from a pre-existing instance or volume.

Many operating system providers have cloud images available for download already. For example, see the image repository from CentOS.

Similarly, other major Linux operating system creators provide images that can be used in OpenStack.

To upload an image, login to Horizon, navigate to Compute, then Images. From there, click the Create Image button. A form will appear where you can fill out the needed details. Click the ? icon for assistance with specifics.

Upload an image:

 

This example will walk through uploading the CirrOS image.

Ensure the image to upload has been downloaded to your machine. CirrOS has been downloaded from the CirrOS download page. The latest version is 0.5.1. Be sure to download the latest version of the image needed.

With the image on your machine, the form details can be filled.

  • Image Details
    • Image Name – specify the name for the uploaded image
    • Image Description – option field used to describe the image
  • Image Source
    • File – this is the location of the image file on your machine
    • Format – the format should be QCOW2 – QEMU Emulator

Optionally, you can specify requirements, like minimum disk space and RAM, for the image under the Image Requirements heading.


Using the command line

You can also view and upload images using OpenStackClient over the command line.

List images

To view available images, use:

$ openstack image list
+--------------------------------------+--------------------------------+--------+
| ID                                   | Name                           | Status |
+--------------------------------------+--------------------------------+--------+
| 6986aaf9-e602-4307-9c4f-6377795ff890 | CentOS 7 (ce7-x86_64)          | active |
| d3f027f2-730f-4794-9288-44ed5c69050d | CentOS 8 (ce8-x86_64)          | active |
| 29c5d143-9fda-4f8e-b364-c2dc29851101 | Debian 10                      | active |
| 6eabc356-c373-4260-8f6f-7d83ff80df21 | Snap-1                         | active |
| 994b6e02-b8c4-4652-80bf-3d56c92b4b19 | Ubuntu 18.04 (bionic-amd64)    | active |
| 20b56b2d-1af5-46e1-a5c6-fa1f9a45245d | Ubuntu 19.10 (eoan-amd64)      | active |
| d35559ff-c9fd-4c18-be8b-1a74eca1eb38 | Ubuntu 20.04 (focal-amd64)     | active |
+--------------------------------------+--------------------------------+--------+

To get more information about an image, run:

$ openstack image show ID

where ID can be the Name or the ID column in the above output.

Example showing the details of an image:

$ openstack image show fa8eb9bd-9ccc-4d3f-b87b-6edb5450a57a --fit-width
+------------------+--------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                            |
+------------------+--------------------------------------------------------------------------------------------------+
| checksum         | 1d3062cd89af34e419f7100277f38b2b                                                                 |
| container_format | bare                                                                                             |
| created_at       | 2020-09-09T20:50:25Z                                                                             |
| disk_format      | qcow2                                                                                            |
| file             | /v2/images/fa8eb9bd-9ccc-4d3f-b87b-6edb5450a57a/file                                             |
| id               | fa8eb9bd-9ccc-4d3f-b87b-6edb5450a57a                                                             |
| min_disk         | 0                                                                                                |
| min_ram          | 0                                                                                                |
| name             | cirros                                                                                           |
| owner            | 5ad1f9e795604f4390d274d7388c4b9f                                                                 |

The output of the above command has been truncated.

Upload an image

To upload an image, run:

openstack image create

For assistance with the CLI options, run:

openstack help image create

OpenStack provides an operating system called CirrOS that has the minimum requirements to be an operating system that is generally used to test instance creation.

To upload this CirrOS image into the glance service, you’ll need to first download it to where the OpenStackClient lives, then the base command openstack image create can be used to upload the image.

Steps to upload the CirrOS image:

Obtain the latest CirrOS image:

$ wget http://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img

Upload the image into glance:

$ openstack image create cirros --container-format bare --disk-format 
qcow2 --file PATH_TO_CIRROS_IMAGE

Note that PATH_TO_CIRROS_IMAGE should be path to the image file.

List the newly uploaded image:

$ openstack image list
+--------------------------------------+--------------------------------+--------+
| ID                                   | Name                           | Status |
+--------------------------------------+--------------------------------+--------+
| fa8eb9bd-9ccc-4d3f-b87b-6edb5450a57a | cirros                         | active |
+--------------------------------------+--------------------------------+--------+

 

Create Image Snapshot

Snapshot using Horizon

An image can also be created from an existing instance by making use of the image snapshot feature.

In the dashboard, look for Compute, then Instances. From there, select an instance, and click Create Snapshot from the drop down on the right.

Create image snapshot:

This will create an image of that instance and the state of the disk will be preserved. You can use this to launch other instances. Should you want to launch an instance using this snapshot, it will be listed in the Launch Instance form under the Select Boot Source dropdown as a volume snapshot.

Create snapshot form:

 

Create Instance form showing the volume snapshot recently created:

Snapshot Using the command line

A snapshot of an instance can be made using the command line with OpenStackClient.

The command to create a snapshot is:

$ openstack server image create --name SNAPSHOT_NAME INSTANCE_NAME
  • SNAPSHOT_NAME is the name to call the snapshot
  • INSTANCE_NAME is the name of the instance the snapshot is created from. The instance UUID could also be used.

After creating a snapshot verify success by:

  • openstack image list
  • openstack image show SNAP_SHOT_UUID – SNAP_SHOT_UUID refers to the UUID of the snapshot made.

Create and verify an instance snapshot

Make a snapshot of the debian_test instance:

$ openstack server image create --name debian_snapshot debian_test --fit-width
+------------------+--------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                            |
+------------------+--------------------------------------------------------------------------------------------------+
| checksum         | d41d8cd98f00b204e9800998ecf8427e                                                                 |
| container_format | bare                                                                                             |
| created_at       | 2020-11-05T16:21:25Z                                                                             |
| disk_format      | qcow2                                                                                            |
| file             | /v2/images/161eb918-f470-4bb8-9572-43ee9eb27ceb/file                                             |
| id               | 161eb918-f470-4bb8-9572-43ee9eb27ceb                                                             |
| min_disk         | 20                                                                                               |
| min_ram          | 0                                                                                                |
| name             | debian_snapshot                                                                                  |
| owner            | 5ad1f9e795604f4390d274d7388c4b9f                                                                 |

List available snapshots:

$ openstack image list --fit-width
+--------------------------------------+--------------------------------+--------+
| ID                                   | Name                           | Status |
+--------------------------------------+--------------------------------+--------+
| 6986aaf9-e602-4307-9c4f-6377795ff890 | CentOS 7 (ce7-x86_64)          | active |
| d3f027f2-730f-4794-9288-44ed5c69050d | CentOS 8 (ce8-x86_64)          | active |
| 29c5d143-9fda-4f8e-b364-c2dc29851101 | Debian 10                      | active |
| 161eb918-f470-4bb8-9572-43ee9eb27ceb | debian_snapshot                | active |
+--------------------------------------+--------------------------------+--------+

The snapshot created is listed as the last entry under ID of 161eb918-f470-4bb8-9572-43ee9eb27ceb.

List details of the snapshot:

$ openstack image show 161eb918-f470-4bb8-9572-43ee9eb27ceb --fit-width
+------------------+--------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                            |
+------------------+--------------------------------------------------------------------------------------------------+
| checksum         | d41d8cd98f00b204e9800998ecf8427e                                                                 |
| container_format | bare                                                                                             |
| created_at       | 2020-11-05T16:21:25Z                                                                             |
| disk_format      | qcow2                                                                                            |
| file             | /v2/images/161eb918-f470-4bb8-9572-43ee9eb27ceb/file                                             |
| id               | 161eb918-f470-4bb8-9572-43ee9eb27ceb                                                             |
| min_disk         | 20                                                                                               |
| min_ram          | 0                                                                                                |
| name             | debian_snapshot                                                                                  |
| owner            | 5ad1f9e795604f4390d274d7388c4b9f                                                                 |