In the past couple of years, Docker has received a tremendous amount of attention. While the concept of containers is hardly anything new (something we at CloudSigma talked more about in this previous post), Docker appears to have become the go-to container manager.
To automatically deploy Docker at CloudSigma, you will need:
- An SSH key.
- Basic understanding of Docker. The official self-paced training course is a great start and of course, the official documentation.
- Basic understanding of CloudInit is beneficial, but by no means necessary.
Assuming you’re already familiar with the basics of Docker, 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 LTS” in the Marketplace). Please ensure that the image shows the CloudInit logo next to it.
Once you’ve attached this image to a new server, feel free to optionally resize it according to your needs. For a quick start, the default 10 GB is sufficient.
Next, ensure you have attached your SSH key to the server you are creating. You can accomplish this using the
SSH Keys tab on your server. The key will be valid for the user
ubuntu on a Ubuntu distro. Please follow this guide to generate private/public key pairs on Windows.
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):
- apt-get update
- curl -fsSL https://get.docker.com/ | sh
- curl -fsSL https://get.docker.com/gpg | sudo apt-key add -
- 2nd Line: Upgrade all packages and brings the system up to date.If you’re not familiar with CloudInit, let’s run through what this does.
- 3rd Line: If the updates on line 5 require a reboot, go ahead and do it.
- 6th Line: Fetch the Docker install script from the docker website and pipe it into sh, which then proceeds to install Docker for us.
- 7th Line: Install the Docker GPG keychain, ensuring that you have fetched the container images securely from the official Docker Hub registry.
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) and you may need to log back in using SSH.
After you have finished with CloudInit, you should now be up and running with Docker:
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Voilá! You now have a server up and running with Docker. This can of course be automated using our API too, in case you need to create multiple servers.
Using CloudInit to instantly turn a VM into an appliance server:
Combining the power of CloudInit and Docker Hub allows us to bring up VMs to serve as specific appliances. For example, adding the following line to CloudInit’s runcmd: will download the Apache container image from Docker Hub and bind it to port 80 on the VM, instantly turning our VM into a web server.
- docker run -dp 80:80 httpd
To ensure this docker container runs every time the VM boots, we add the following line to CloudInit, which inserts the command to our /etc/rc.local startup file.
- echo "docker run -dp 80:80 httpd" > /etc/rc.local
Running OwnCloud using Docker on CloudSigma
Another popular service you can deploy in a jiffy is OwnCloud, the Open Source Dropbox alternative. To do so, replace
httpd in the last two lines with
- docker run -dp 80:80 owncloud
- echo "docker run -dp 80:80 owncloud" > /etc/rc.local
Give your VM a few minutes to update and set things up. Now type in the IP address of your VM into any web browser, and you should see the following:
Voilá! At CloudSigma, you can tailor your Docker VM’s CPU, RAM and storage parameters to perfectly match your Docker container performance requirements. In The OwnCloud example, a VM with a large amount of storage would be best.
We encourage you to browse Docker Hub where you will find an extremely rich choice of services and appliances that you can instantly deploy on CloudSigma’s powerful IaaS cloud. For a more detailed overview of how you can contextualise your CloudSigma VMs using CloudInit, please review CloudSigma’s introduction to server provisioning with CloudInit.
- How to Run Docker on CloudSigma (with CloudInit) Updated - June 30, 2016
- Successful End to the First Year of CloudSME - October 7, 2014