Feel++

Installation

This section covers briefly the installation of Docker. It should be a relatively simple smooth process to install Docker.

Channels

Docker offers two channels: the stable and beta channels.

stable channel

is fully baked and tested software providing a reliable platform to work with. Releases are not frequent.

beta channel

offers cutting edge features and experimental versions of the Docker Engine. This is a continuation of the initial Beta program of Docker to experiment with the latest features in development. It incurs far more instabilities than the stable channel but releases are done frequently — possibly several releases per month.

In the latter we shall consider only installing and using the stable channel.

Installing Docker

At the time of writing this section, Docker is available on Linux, Mac and Windows.

Mac and Windows

The support for Mac and Windows as Host OS was recently released and Docker Inc provides installation processes Docker For Mac and Docker for Windows which are the recommended way of installing Docker on these platforms.

Linux

Most Linux distributions have their own packages but they tend to lag behind the stable releases of Docker which could be a serious issue considering the development speed of Docker.

To follow Docker releases, it is probably best to use the packages distributed by Docker.

Installing Binaries

The last possibility is to use Docker Binaries to install Docker. This should be used at the last resort if packages are provided neither by your distribution nor by Docker Inc.

Tested with Docker 1.12

At the time of writing this book, the Docker version we used is Docker 1.12. All commands have been tested with this version.

Running without sudo

On Linux, Docker is a priviledged binary, you need to prefix all your commands with sudo, e.g. on Ubuntu. You need first to belong to the docker group with the following command on Ubuntu

$ sudo usermod -aG docker

It creates the docker group if it doesn’t already exist and adds the current user to the docker group. Then you need to log out and log in again. Similar process is available on other distributions. You need also to restart the docker service

$ sudo service docker restart
From now on, we omit the sudo command when using Docker for the sake of brevity.
Adding a user to the docker group has security implications. On a shared machine, you should consider reading the Docker security page.

Checking Docker

We now check your installation by running docker version To make sure everything is installed correctly and working, try running the docker version command. You should see something like the following on Linux or Mac.

Listing : Output of docker version on Linux
> docker version
Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Mon, 10 Oct 2016 21:38:17 +1300
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Mon, 10 Oct 2016 21:38:17 +1300
 OS/Arch:      linux/amd64
Listing : Output of docker version on Mac
> docker version
Client:
Version: 1.12.6
API version: 1.24
Go version: go1.6.4
Git commit: 78d1802
Built: Wed Jan 11 00:23:16 2017
OS/Arch: darwin/amd64

Server:
Version: 1.12.6
API version: 1.24
Go version: go1.6.4
Git commit: 78d1802
Built: Wed Jan 11 00:23:16 2017
OS/Arch: linux/amd64

If so, you are ready for the next step. If instead you get something like

Listing : Bad response output of docker version on Linux
> docker version
Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Mon, 10 Oct 2016 21:38:17 +1300
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Listing : Bad response output of docker version on Mac
> docker version
Client:
 Version:      1.12.6
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   78d1802
 Built:        Wed Jan 11 00:23:16 2017
 OS/Arch:      darwin/amd64
Error response from daemon: Bad response from Docker engine

then it means that the Docker daemon is not running or that the client cannot access it.

To investigate the problem you can try running the daemon manually — e.g. sudo docker daemon. This should give you some informations of what might have gone wrong with your installation.