If you have anything to do with web or app development, you’ll almost certainly have heard of containerisation and the benefits it can provide. But if you haven’t actually got your hands on software containers yet, where do you start?
Docker is the world’s most popular container platform. It automates container deployment, including the repetitive processes of setting up development environments. By managing all this, Docker helps devs free up more time for coding.
Why use Docker?
One of the main advantages of containerisation is that it lets you, in Docker’s own words, ‘escape the app dependency matrix’. That is, it provides an antidote to the dreaded ‘well, it works on my machine’ syndrome.
Docker container images come pre-packaged with all the required dependencies, easily portable across machines and infrastructures. So when containers are created from these images, they’ll behave predictably wherever they end up.
There’s no need to worry about creating the exact environment required for a specific project, because Docker containers will run the same way on everyone’s machine. This saves the time taken to install and maintain software on multiple PCs and servers, and drastically cuts down on supporting documentation.
Docker ensures each container has its own resources, completely isolated from other containers. The built-in container orchestration known as ‘swarm clustering’ also allows users to quickly spin up thousands of them.
Container images can be easily accessed and shared via Docker repositories and registries that can be synchronised across a whole organisation. Version control is also simplified, with the option to easily roll back to previous container images.
Another major benefit for Docker users is full integration for a wide range of popular tools including Puppet, Kubernetes, Jenkins and many more, as well as features to work seamlessly with existing storage and networking resources.
How to install Docker on a Linux cloud server
If you want to start using Docker now, CloudNX, our next generation cloud hosting platform, offers the ideal environment. To install Docker on a CloudNX virtual machine, you’ll need:
- A 64-bit Linux server with a static IP address running either Ubuntu 14.04 or CentOS 7
- Kernel version 3.10 or higher
To install Docker on Ubuntu 14.04:
First, you need to update your package info and make sure CA certificates are installed with these commands:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
Then, add the new GPG key:
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Next you’ll need to create a Docker repository. To do this, create a file named docker.list in the etc/apt/sources.list.d directory:
sudo nano etc/apt/sources.list.d/docker.list
And add this to the file:
deb https://apt.dockerproject.org/repo ubuntu-trusty main
Save the file and exit, and update APT with these commands:
sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-cache policy docker-engine
Then install Docker using the command:
sudo apt-get install docker-engine
After Docker has been installed, start the service by running this command:
sudo service docker start
(Note that this installation process will automatically configure Upstart to start Docker on boot)
To install Docker on CentOS 7:
Before you install Docker on CentOS 7, you need to update your system. So run:
sudo yum -y update
Create a Docker repository by creating a file named docker.repo in the etc/yum.repos.d directory:
sudo nano etc/yum.repos.d docker.repo
And add the following to the file:
Save the file and exit, then install Docker by running this command:
sudo yum install docker-engine
Once you’ve installed Docker, run the following command to start the service:
sudo systemctl start docker.service
To set the Docker service to start on boot, use the command:
sudo systemctl enable docker.service
Work with Docker safely without using Sudo
Because the Docker daemon runs as root, users are required to use sudo if they want to run Docker commands. To avoid this, just add your user or users to the docker group using the command:
usermod -aG docker [username]
And with that, you’re ready to go! Be sure to check back for more news on cloud computing and containerisation, and keep an eye on the Fasthosts website for product updates.