Although you may not gain full capabilities of docker when you mix it with OpenStack, (like network capabilities and …) it’s a suitable solution to get benefit of OpenStack Dashboard in order to manage containers.
Here I’m going to teach you how you can use docker as an hypervisor in OpenStack Kilo with help of nova-docker on CentOS 7.
After setting up OpenStack, first thing is first, installing docker itself:
# yum install docker
# systemctl start docker
# systemctl enable docker
And fetching nova-docker repository from git:
# git clone http://github.com/stackforge/nova-docker.git
# cd nova-docker
# git checkout -b kilo origin/stable/kilo
# git branch -v -a
* kilo d556444 Do not enable swift/ceilometer/sahara
master d556444 Do not enable swift/ceilometer/sahara
remotes/origin/HEAD -> origin/master
remotes/origin/master d556444 Do not enable swift/ceilometer/sahara
remotes/origin/stable/icehouse 9045ca4 Fix lockpath for tests
remotes/origin/stable/juno b724e65 Fix tests on stable/juno
remotes/origin/stable/kilo d556444 Do not enable swift/ceilometer/sahara
And now installing the package:
# python setup.py install
We need to adjust suitable permissions:
# chmod 666 /var/run/docker.sock
# mkdir /etc/nova/rootwrap.d
in nova.conf set compute_driver to:
compute_driver = novadocker.virt.docker.DockerDriver
and change the firewall_driver to:
firewall_driver=nova.virt.firewall.NoopFirewallDriver
then, you need to create docker.filters file:
# nano /etc/nova/rootwrap.d/docker.filters
and paste:
# nova-rootwrap command filters for setting up network in the docker driver
# This file should be owned by (and only-writeable by) the root user
[Filters]
# nova/virt/docker/driver.py: 'ln', '-sf', '/var/run/netns/.*'
ln: CommandFilter, /bin/ln, root
add following line to /etc/glance/glance-api.conf:
container_formats=ami,ari,aki,bare,ovf,ova,docker
restart corresponding services:
# systemctl restart openstack-nova-compute
# systemctl restart openstack-glance-api
Now, it’s time to download a docker image and upload it to glance:
# docker pull tutum/ubuntu:latest
# docker save tutum/ubuntu:latest | glance image-create --name "tutum/ubuntu:latest" --disk-format raw --container-format docker --visibility public --progress
Note that glance image name must be the same as docker image name.
Last but not least, create an instance from dashboard and open instance’s log tab to find out the password, and make ssh connection to the container.