Using docker machine for simple setup of docker engines on OpenStack lets you leverage the power of the cloud in combination with docker. Personally, I’m using docker machine provisioned docker engines on Elastx openstack:IaaS to move compute and bandwidth needs to our cloud platform instead of my laptop. Alright, everybody know that they should love docker so let’s get to it.
If you haven’t already, start by loading up your openrc.sh to set up the environment in your shell:
I’m going to assume that the reader of this blogpost (that’s you!):
Know how to setup networking that suits your use-case in openstack:IaaS, including:
- Router, network, subnet
- Allocate floating IPs to your project
- Setup security groups properly for docker engines provisioned using docker machine
- Allow at a minimum TCP ports for SSH & port 2376 for communication with the docker engine.
- Get ID’s for flavors and images
After you’ve gathered the information you need about the networking, nova flavors and glance images, we’ll go ahead and create an instance running docker engine, using docker machine:
$ docker-machine create --driver openstack \ --openstack-flavor-id a2104f1d-c639-4de6-846e-29b63b14a8e7 \ --openstack-floatingip-pool ext-net-01 \ --openstack-image-id a9a5f052-64da-43a1-911b-dbdceb139854 \ --openstack-net-id bc492626-0c40-4ac0-9002-44981b7817bb \ --openstack-sec-groups default,dockermachines \ --openstack-ssh-user ubuntu \ dm01
Walkthrough of the arguments passed to docker-machine:
- --openstack-flavor-id: I passed the value that represents m1.medium in Elastx
- --openstack-floatingip-pool: Name of the floating IP pool to use.
- --openstack-image-id: ID of the glance image to be used for creating the docker machine, in this case, I passed on the value of a public Ubuntu 14.04 image.
- --openstack-net-id: Network id to attach to.
- --openstack-sec-groups: Security groups to use, make sure you attach to a SG which allows you to SSH to the instance from where you are running docker-machine.
- --openstack-ssh-user: Username that docker-machine will use for accessing the instance over SSH, set to ubuntu for the particular image used in this blog post.
- The last argument (dm01 here) is the name of the docker machine created.
If docker-machine outputs indicates happy computers and great success, you should now be able to setup your shell environment for communication with the created docker engine:
$ eval $(docker-machine env dm01)
And after that, you should be able to work with docker as usual:
$ docker run -ti busybox echo 'Yo, world!' Unable to find image 'busybox:latest' locally latest: Pulling from library/busybox c00ef186408b: Pull complete ac6a7980c6c2: Pull complete Digest: sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0 Status: Downloaded newer image for busybox:latest Yo, world!
So, that’s basically it, that’s how simple you can get a docker engine up and running using docker machine on ELASTX Openstack IaaS.