First, you need to have knowledge of a few pre-requisites:
- An SSH key.
- Basic understanding of Docker. The official documentation is a great start.
- Basic knowledge of CloudInit
In the recent year or so, Docker has received a tremendous amount of attention. It appears to be one of those things where the timing was just perfect. While the concept of containers is hardly anything new (which I talked more about in this previous post), Docker appears to have become the go-to container manager.
Assuming you’re already familiar with the basics of the container manager, you might be interested in the easiest way to deploy Docker on CloudSigma.
As it turns out, this is very simple to automate. What we’ll be using is CloudInit and Ubuntu’s Cloud Images (named “Ubuntu 14.04 Cloud Image” in the Marketplace).
Once you’ve cloned this and created a server with this image, go ahead and resize it. The template image is just slightly larger than 2GB, which isn’t sufficient for this. 5-15GB is more suitable.
With that done, click on the new ‘CloudInit’ link under the Properties of your server.
Now paste in the following and press ‘Activate’ (and then save your server):
[bash] #cloud-configpackage_upgrade: true
package_reboot_if_required: true
ssh_authorized_keys:
– Your-Public-SSH-Key
packages:
– docker.io
runcmd:
– ln -sf /usr/bin/docker.io /usr/local/bin/docker
– sed -i ‘$acomplete -F _docker docker’ /etc/bash_completion.d/docker.io
final_message: "Your Docker server is now ready."
[/bash]
If you’re not familiar with CloudInit, let’s run through what this does.
- Line2: Upgrade all packages and brings the system up to date.
- Line3: If the updates on line one requires a reboot, go ahead and do it.
- Line4-5: Then, tell the system to install the public SSH key (Your-Public-SSH-Key) to the user ‘ubuntu’
- Line6-7: After that, install the package ‘docker.io’. This also implies ‘package_update: true’.
- Line8-10: Usability enhancement from the official installation guide.
- Line11: Finally, display a message when done.
Shortly after you’ve booted up the server, you should be able to SSH into the server using your SSH key. Depending on the number (and types) of updates, your server may or may not reboot (Line 3 above). As a result, you may not see the final message.
After CloudInit is ready, you should now be up and running with Docker:
[bash light=”true”] $ ssh ubuntu@a.b.c.d "sudo docker ps"CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[/bash]
Finally, you now have a server up and running. This can of course be automated using our API too, in case you need to create multiple servers.
- Manage Docker resources with Cgroups - May 12, 2015
- Docker, Cgroups & More from ApacheCon 2015 - April 30, 2015
- How to setup & optimise MongoDB on public cloud servers - March 24, 2015
- Presentation deck from CloudExpo Europe - March 17, 2015
- CoreOS is now available on CloudSigma! - March 10, 2015