Docker has become more popular among developers as a platform to automate deployment of applications inside software containers within cloud servers. It is very easy for developers to deploy their applications on a Docker container, save the container image, and then, manually or automatically, deploy the application image in other Docker-enabled cloud servers without having to worry about the underlying operating system or environment settings.
It is possible to install Docker on a virtual machine running virtualization technology. In this guide, we will provide you with step-by-step instructions on how to install Docker 1.10.2 on a Ubuntu 14.04.3 LTS (64-bit) virtual machine. The example below was done on a Plan XS (1 GB) cloud server (virtual machine) hosted in SimplerCloud using root account, therefore the “sudo” command was omitted on most of the steps. If you are using a non-root user with sudo access, please append “sudo” in front of each command (e.g. “sudo apt-get update” instead of “apt-get update“).
Prerequisites for Installing Docker on Ubuntu
These are the pre-requisites for installing Docker on an Ubuntu server:
- A virtual machine or physical server running 64-bit installation of Ubuntu. Note that 32-bit installation of Ubuntu is not supported. Below are the Ubuntu versions officially supported by Docker:
In this guide, we will be using Ubuntu Trusty 14.04.3 LTS (64-bit), which is the latest LTS (Long Term Support) version of Ubuntu at the time of writing this article.
- Minimum kernel version of Ubuntu is 3.10 or higher. To check your kernel, run “uname -r” from the virtual machine’s SSH terminal.
Based on the above, we can see that the kernel version is 3.13, which meets the requirement. If the kernel version is lower than 3.10, upgrade the kernel first using below commands and restart the server for the changes to take effect:
apt-get dist-upgrade –y
- An SSH client such as Putty, and basic knowledge on how to use the SSH client to access your virtual machine.
- Basic knowledge on some Unix commands to access your virtual machine via SSH.
Step 1 – If you haven’t done so, please update your Ubuntu OS and install the latest patches by running below commands:
apt-get dist-upgrade -y
Reboot your server after the update for the changes to take effect.
Step 2 – To ensure that aufs storage driver is supported by Docker, install the linux-image-extra kernel package by typing below command and reboot your server once completed :
apt-get install linux-image-extra-$(uname -r)
On the test virtual machine we are using, the linux-image-extra package is already installed by default (see screenshot below).
Step 3 – Set your Ubuntu’s APT sources to work with https method and CA certificates are installed by running below command:
apt-get install apt-transport-https ca-certificates
Note that normally both packages are already installed by default in many Ubuntu virtual machines. Below example shows that the packages are already installed:
Step 4 – Add the Docker repository’s GPG keys for verification:
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Step 5 – Add the Docker repository into your Ubuntu’s APT sources by running below command:
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
Step 6 – Run apt-get update to update your package index:
apt-get update -y
Step 7 – Install the Docker engine by running below command:
apt-get install docker-engine
Type “Y” to continue, and wait until the Docker Engine installation is completed.
Step 8 – The Docker daemon should be started automatically once the installation is completed. You can verify by running below commands:
service docker status
ps awx | grep docker
Step 9 – If the Docker daemon is not started, you can start it using below command:
service docker start
Step 10 – To verify that your Docker daemon is running properly, run below docker command:
docker run hello-world
The command will try to run the hello-world default image, and to pull it from Docker library if it doesn’t exist locally.
Congratulations! You have installed Docker on your virtual machine.
The next step is to create a Docker image and run a new Docker container (tutorial coming soon).
Disclaimer : This is a guest post article by Indra Pramana from SimplerCloud.com, a cloud servers provider from Singapore with solutions built from the ground up to provide truly real-time, scalable and easily managed cloud infrastructure for start-ups, developers and business throughout Asia.