When Docker boots a container, it will need to start the container from a Docker image, similar to how it needs to start a virtual machine from a disk image. Nova will need to pull this container from Glance. This means that Glance needs to know how to manage Docker containers. In Mitaka, Glance knows how to handle Docker containers by default. This can be confirmed by looking in the /etc/glance/glance-api.conf
file and verifying that docker
is listed in the container_formats
list. Note that container of container_formats
here does not refer to a docker
container. It is related to the storage capabilities that Glance has.
Now that it has been confirmed that Glance can manage the Docker container, one must be imported into Glance and made available to boot a container instance. To do this, you use Docker to get images and then import them into Glance so they are available to Nova at spawn time for the instance. Docker needs to be installed and running on the host you do this from and you must execute the OpenStack command-line client. Let's do this work on the undercloud since that is where you have been sourcing the overcloudrc
file. Start by making sure that Docker is installed and running:
undercloud$ sudo yum install docker -y undercloud$ sudo systemctl start docker undercloud$ sudo systemctl enable docker
Next, use Docker to download the CentOS Docker image. This will have to be done as the root user as permissions have not been set up for non-root users to connect to the docker
daemon. The pull
command will copy the Docker image into Docker's image store. You can see the downloaded image using the Docker images
command:
undercloud$ sudo docker pull centos undercloud$ sudo docker images
Finally, export the Docker image using Docker's save
command and pipe the data to the OpenStack's image create
command:
undercloud$ source overcloudrc undercloud$ sudo docker save centos | openstack image create centos --public --container-format docker --disk-format raw
Also, pay attention to the permissions that these commands run with. The docker
command is running sudo
to connect to the docker
daemon and the data is being piped to the openstack
command that is no longer being run as root. The openstack
command is connecting to OpenStack using the admin user's credentials. You should only load Docker images into OpenStack using the admin user.
Using the OpenStack's image list
command, you will see the CentOS image that you imported. Doing an image show
on the instance node that the container-format has been specified as docker
:
undercloud$ openstack image list undercloud$ openstack image show docker-centos
18.118.144.248