Installing the Docker engine
The Docker engine is built on top of the Linux kernel and it extensively leverages its features. Therefore, at this point in time, the Docker engine can only be directly run on Linux OS distributions. Nonetheless, the Docker engine could be run on the Mac and Microsoft Windows operating systems by using the lightweight Linux VMs with the help of adapters, such as Boot2Docker. Due to the surging growing of Docker, it is now being packaged by all major Linux distributions so that they can retain their loyal users as well as attract new users. You can install the Docker engine by using the corresponding packaging tool of the Linux distribution; for example, by using the apt-get
command for Debian and Ubuntu, and the yum
command for RedHat, Fedora, and CentOS.
Note
We have chosen the Ubuntu Trusty 14.04 (LTS) (64-bit) Linux distribution for all practical purposes.
Installing from the Ubuntu package repository
This section explains the steps involved in installing the Docker engine from the Ubuntu package repository in detail. At the time of writing this book, the Ubuntu repository had packaged Docker 1.0.1, whereas the latest version of Docker was 1.5. We strongly recommend installing Docker version 1.5 or greater by using any one of the methods described in the next section.
However, if for any reason you have to install the Ubuntu packaged version, then please follow the steps described here:
- The best practice for installing the Ubuntu packaged version is to begin the installation process by resynchronizing with the Ubuntu package repository. This step will essentially update the package repository to the latest published packages, thus we will ensure that we always get the latest published version by using the command shown here:
$ sudo apt-get update
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
- Kick-start the installation by using the following command. This setup will install the Docker engine along with a few more support files, and it will also start the
docker
service instantaneously:$ sudo apt-get install -y docker.io
Note
The Docker package is called
docker.io
because an older version of the Ubuntu package was calleddocker
. As a result, all the files with the namedocker
are installed asdocker.io
.Examples are
/usr/bin/docker.io
and/etc/bash_completion.d/docker.io
. - For your convenience, you can create a soft link for
docker
.io
calleddocker
. This will enable you to execute Docker commands asdocker
instead ofdocker.io
. You can do this by using the following command:$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
Note
The official Ubuntu package does not come with the latest stable version of
docker
.
Installing the latest Docker using docker.io script
The official distributions might not package the latest version of Docker. In such a case, you can install the latest version of Docker either manually or by using the automated scripts provided by the Docker community.
For installing the latest version of Docker manually, follow these steps:
- Add the Docker release tool's repository path to your APT sources, as shown here:
$ sudo sh -c "echo deb https://get.docker.io/ubuntu \ docker main > /etc/apt/sources.list.d/docker.list"
- Import the Docker release tool's public key by running the following command:
$ sudo apt-key adv --keyserver \ hkp://keyserver.ubuntu.com:80 --recv-keys \ 36A1D7869245C8950F966E92D8576A8BA88D21E9
- Resynchronize with the package repository by using the command shown here:
$ sudo apt-get update
- Install
docker
and then start thedocker
service.$ sudo apt-get install -y lxc-docker
Note
The lxc-docker
command will install the Docker image using the name docker
.
The Docker community has taken a step forward by hiding these details in an automated install script. This script enables the installation of Docker on most of the popular Linux distributions, either through the curl
command or through the wget
command, as shown here:
- For curl command:
$ sudo curl -sSL https://get.docker.io/ | sh
- For wget command:
$ sudo wget -qO- https://get.docker.io/ | sh
Note
The preceding automated script approach enforces AUFS as the underlying Docker file system. This script probes the AUFS driver, and then installs it automatically if it is not found in the system. In addition, it also conducts some basic tests upon installation for verifying the sanity.