OpenStack Images can take several forms, but generally an image consists of a static copy of a virtual machine with an operating system with some amount of storage. Each project starts out with a few base Linux and Windows images from which instances can be created. Images can also be created or uploaded to OpenStack, and then used to launch instances.
In OpenStack, there are several stock images from which you can easily launch new instances. Typically you will want to create an instance from one of these stock images. You can view the available images (once logged in) by going to the "Images" tab in the Web Interface.
You would only need to create/upload your own image if you are unhappy with the stock images available, or if you would like to make an image from one of your current instances (to easily launch new instances with the same software and data). Currently, we have images for:
Creating an Image
From an Instance
Snapshots in OpenStack can be used like images, so the simplest way to create an image from an instance is to create a snapshot:
- Shut Off the instance by selecting "Shut Off Instance" for the instance from the Instances tab
- Create a snapshot of the instance by selecting "Create Snapshot" for the instance
- You will have to give the snapshot a name (this will be the name of your image)
- Wait for the snapshot to finish being created, and it will show up on the Images tab
Note: You should not take a snapshot of a file system that's mounted. You will lose all the info that's still in Linux's write cache. So if you want to take a snapshot of the root file system, the OS cannot be running.
From a Volume
Create an image from the volume:
- Select "Upload Volume to Image" for the volume from the Volumes tab
- Give the image a name and select "Upload"
- Wait for the image to finish being created, and it will show up on the Images tab
You can now launch new instances from the image.
If you have a volume snapshot that you would like to create an image from, create a volume from the snapshot, then follow the above steps.
Upload an Image
Images can be uploaded if you already have an image file that you would like to use. For example, if you are unsatisfied with the stock image options available on Red Cloud, you can Get Images from elsewhere. Images can be uploaded via the Web Interface:
- Go to the Images tab
- Select the "Create Image" option
- Give the image a name
- Select the file of the source image to upload
- Select "Raw" for the Format
- Optional: Select "Yes" under Protected to ensure that the image cannot be changed or deleted accidentally (this setting can be changed later)
- Select "Create Image"
You can share an image from your project with a collaborator in a different project in OpenStack cloud so you can both launch instances using the same image. As the owner of the image, you can revoke the sharing privilege at any time. You can also use these methods to share an image with yourself in other projects, just think of yourself as the collaborator.
- Both you and your collaborator need to use the OpenStack CLI
- You will need to know the project name or ID of your collaborator.
- Find the project ID of your collaborator. Run
openstack project list | grep <collaborator's project name>
- and the first field of the output is the ID of your collaborator's project ID.
- Find the ID of the image you want to share:
openstack image show <image name>
- Share the image with your collaborator's project:
openstack image set --shared <image ID> openstack image add project <image ID> <collaborator's project ID>
- Verify the image is now shared. The status field should say
pendinguntil your collaborator accepts the image.
openstack image member list <image ID>
- Give the ID of the shared image to your collaborator.
- Currently this action can only be performed by cloud administrators.
- This generally shouldn't be done unless creating something that is a public resource that is intended to be used with any project.
- Additionally, don't use such an image from a third party unless you trust the source.
openstack image set --public <image ID>
- Get the ID of the shared image from the owner. Make sure the owner has performed the steps in the Share an Image section above.
- Accept the shared image:
openstack image set --accept <image ID>
- Verify the image is now available to your project:
openstack image list
- If the image is listed in the output, it should also appear in Openstack web console (Horizon).
- An image's owner can see which projects have access to the image:
openstack image member list <image ID>
- The owner can unshare an image like this:
openstack image remove project <image ID> <project ID>