In case you're not familiar with Docker, here is the summary of it
and its functionality:
Docker is an open-source engine which automates the deployment of applications as highly portable, self-sufficient containers which are independent of hardware, language, framework, packaging system and hosting provider.
In this tutorial, we're going to build and install Docker on a fresh Ubuntu 13.04 VPS (cloud server) instance from DigitalOcean.
Why Build it?
Docker is still in Alpha, and as such, there's considerable changes and fixes daily. Plus, if you find anything you'd like to improve or fix yourself, it's much easier to contribute if you're already building from source!
Step 1: Create the Virtual Private Server
Docker currently only supports Ubuntu 12.04, 12.10, and 13.04, and only in 64bit architecture. It's currently slightly simpler to install Docker on Ubuntu 13.04 x64.
Create the VPS and once it's done, go ahead and SSH in.
Step 2: Setup the VPS
First, set up a user account, so that we have a place to keep Go and Docker (The user's Home directory). Here, replace USER with your own username.
sudo useradd -m -d /home/USER -s /bin/bash -U USER
Give yourself a password with:
passwd USER
For the purposes of this tutorial, we'll give this user all privileges for use of the sudo command; let's add a group called admin and add our new user to it. This will allow them use of the sudo command.
groupadd admin && usermod -a -G admin USER
Login with:
su USER
We'll use our home directory to store both Go and the Docker repository, so enter it now with:
The documentation refers to the $GOPATH variable as:
a colon-separated list of paths inside which Go code, package objects, and executables may be found.
Our $GOPATH is where we're going to be storing all of the Docker source and dependencies. Later on, this will let us build Docker with the Go install command, which is handy.
cd $GOPATH/src/github.com/dotcloud
git clone https://github.com/dotcloud/docker.git
We can now use Go's helpful go get function to download and install the packages and dependencies we need to build Docker:
cd $GOPATH/src/github.com/dotcloud/docker
go get -v github.com/dotcloud/docker/...
This will also install Docker. To allow us to run the Docker executable as root without specifying the full path, we can symlink it to /usr/local/bin with:
After the previous command has been executed and started, hitting Enter will keep Docker running in the background. Let's test it out! First, pull the base container image:
docker pull base
Once it's downloaded, test launch a new container with:
docker run -t base /bin/echo "Hello, world."
Updating Docker is now as simple as stopping the instance, deleting the binary, pulling the repository, using Go install, and restarting Docker:
If you're still new to Docker, there's already a few great resources to get you started: The
Docker Index is a place you can find community-made Docker images, ready to Docker pull into your new installation. If you'd prefer to build a few Dockerfiles yourself, there's a good collection to be found here.