Running Docker Machine on Rackspace Public Cloud
Next up I am giving Docker Machine on Rackspace public cloud a whirl. If you don’t have an account and want to check it out take a look at their developer+ credit.
Here is a gif diagram (I’m addicted to making gifs atm, sometimes not even cats doing cute fluffy cat stuff like here) overviewing Docker Machine. To get installed and much more on docker and docker machine check out the excellent docs at docs.docker.com
Create a Docker Machine
First head over to your Rackspace console and grab your UID, and your API key. If you are knowledgable about OpenStack, the CLI options should look pretty familiar (thats pretty cool btw). You can also you ENVs for some of the values listed in the docker-machine docs one overriding the other.
1 2 3 4 5 6 7 8 9 10 11 12 |
Options: --rackspace-api-key Rackspace API key [$OS_API_KEY] --rackspace-docker-install "true" Set if docker have to be installed on the machine --rackspace-endpoint-type "publicURL" Rackspace endpoint type (adminURL, internalURL or the default publicURL) [$OS_ENDPOINT_TYPE] --rackspace-flavor-id "general1-1" Rackspace flavor ID. Default: General Purpose 1GB [$OS_FLAVOR_ID] --rackspace-image-id Rackspace image ID. Default: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) --rackspace-region Rackspace region name [$OS_REGION_NAME] --rackspace-ssh-port "22" SSH port for the newly booted machine. Set to 22 by default --rackspace-ssh-user "root" SSH user for the newly booted machine. Set to root by default --rackspace-username Rackspace account username [$OS_USERNAME] |
Rackspace VM flavors are listed here
Next lets spin up the instance using an image flavor-id of ‘2’ which is the smallest 512MB machine. I specified the region ID that was listed in the Rackspace Console.
1 2 3 4 5 6 7 8 9 |
docker-machine create \ --driver rackspace \ --rackspace-username <$USERNAME> \ --rackspace-api-key <$SUPER_SECRET_KEY> \ --rackspace-flavor-id 2 \ --rackspace-region IAD \ racker-test-instance |
And voila, we have an instance that is now our active instance in docker-machine:
1 2 3 4 5 6 7 8 |
$ dml NAME ACTIVE DRIVER STATE URL SWARM dev virtualbox Running tcp://192.168.99.100:2376 machine-name12345 azure Running tcp://machine-name12345.cloudapp.net:2376 racker-test-instance * rackspace Running tcp://162.209.126.37:2376 test-instance amazonec2 Running tcp://52.5.11.81:2376 |
Run some Docker Containers on Rackspace
Now load the environmental variables for the Rackspace instance:
1 2 3 |
eval "$(docker-machine env racker-test-instance)" |
You can then verify with env | grep DOCK
1 2 3 4 5 6 7 |
$ eval "$(docker-machine env racker-test-instance)" $ env | grep DOCK DOCKER_HOST=tcp://162.209.126.37:2376 DOCKER_TLS_VERIFY=1 DOCKER_CERT_PATH=/Users/brent/.docker/machine/machines/racker-test-instance |
Now start spin up some containers:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ docker run busybox echo hello world Password: Unable to find image 'busybox:latest' locally latest: Pulling from busybox cf2616975b4a: Pull complete ... Status: Downloaded newer image for busybox:latest hello world $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 31cb98825df0 busybox:latest "echo hello world" 14 seconds ago Exited (0) 14 seconds ago sleepy_sammet |
or fire up a webserver mapping port 80 to port 8000:
1 2 3 |
docker run -d -p 8000:80 nginx |
Now grab the IP and open a socket to the server for funs:
1 2 3 4 |
$ docker-machine ip racker-test-instance $ curl <ip>:8000 |
or even more clever from the docker machine docs this:
1 2 3 4 |
$ curl $(docker-machine ip racker-test-instance):8000 <title>Welcome to nginx!</title> |
I was impressed how easy it was to consume resources from Rackspace Pub Cloud using machine. Thanks to my pal @andyhky from Rackspace getting a test account for me. If you dont already read his blog, check it out for some netops meets devops funz. Rackspace has a nice detailed blog entry that I didn’t see until I finished this so that leaves lots of resources in case anyone gets blocked. Check it here.
Next up is Docker Machine on Digital Ocean Pub Cloud →
Thanks for stopping by!