Installing docker on ubuntu

Installing docker on an ubuntu 16.04 Virtual Machine

Bibliography

Docker documentation: https://docs.docker.com/engine/installation/linux/ubuntulinux/

Let’s go

I basically followed the documentation available in the bibliography. Here are the commands I entered and the results:

Prerequisites

Reference

https://docs.docker.com/engine/installation/linux/ubuntulinux/#/prerequisites

Input

uname -r

Output

4.4.0-36-generic

Analysis

My kernel it’s 4.4.x, that’s fine.

Input

sudo apt-get update

Output

Trovato:1 http://it.archive.ubuntu.com/ubuntu xenial InRelease
Scaricamento di:2 http://it.archive.ubuntu.com/ubuntu xenial-updates InRelease [95,7 kB]
Scaricamento di:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [94,5 kB]
...
Recuperati 1.285 kB in 12s (103 kB/s)
Lettura elenco dei pacchetti... Fatto

Analysis

My APT index it’s updated.

Input

sudo apt-get install apt-transport-https ca-certificates

Output

Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze
Lettura informazioni sullo stato... Fatto
ca-certificates is already the newest version (20160104ubuntu1).
apt-transport-https is already the newest version (1.2.12~ubuntu16.04.1).
0 aggiornati, 0 installati, 0 da rimuovere e 3 non aggiornati.

Analysis

The apt-transport-https and ca-certificates packages were already installed.

Input

sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Output

Executing: /tmp/tmp.R97nJLsyWy/gpg.1.sh --keyserver
hkp://p80.pool.sks-keyservers.net:80
--recv-keys
58118E89F3A912897C070ADBF76221572C52609D
gpg: richiesta della chiave 2C52609D dal server hkp p80.pool.sks-keyservers.net
gpg: chiave 2C52609D: chiave pubblica "Docker Release Tool (releasedocker) <docker@docker.com>" importata
gpg: Numero totale esaminato: 1
gpg:               importate: 1  (RSA: 1)

Analysis

It looks good, the key it’s from them.

Input

sudo nano /etc/apt/sources.list.d/docker.list

Delete everything (if present) and paste just this line:

deb https://apt.dockerproject.org/repo ubuntu-xenial main

Exit and save.

Analysis

We added the docker repos the the APT list.

Input

sudo apt-get update

Output

Scaricamento di:1 https://apt.dockerproject.org/repo ubuntu-xenial InRelease [30,2 kB]
Scaricamento di:2 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages [2.313 B]
Scaricamento di:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [94,5 kB]
Trovato:4 http://it.archive.ubuntu.com/ubuntu xenial InRelease
Trovato:5 http://it.archive.ubuntu.com/ubuntu xenial-updates InRelease
Trovato:6 http://it.archive.ubuntu.com/ubuntu xenial-backports InRelease
Recuperati 127 kB in 10s (12,0 kB/s)
Lettura elenco dei pacchetti... Fatto

Analysis

The APT index it’s update also from the the new repos added.

Input

sudo apt-get purge lxc-docker

Output

Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze
Lettura informazioni sullo stato... Fatto
Il pacchetto "lxc-docker" non è installato e quindi non è stato rimosso
0 aggiornati, 0 installati, 0 da rimuovere e 3 non aggiornati.

Analysis

There was no need to purge the packet because it wasn’t already installed.

Input

apt-cache policy docker-engine

Output

docker-engine:
  Installato: (nessuno)
  Candidato:  1.12.1-0~xenial
  Tabella versione:
     1.12.1-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
     1.12.0-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
     1.11.2-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
     1.11.1-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
     1.11.0-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages

Analysis

It’s getting it from the xenial repo so it’s fine for ubuntu 16.04

Installing

Reference

https://docs.docker.com/engine/installation/linux/ubuntulinux/#/install

Input

sudo apt-get update

Output

Trovato:1 https://apt.dockerproject.org/repo ubuntu-xenial InRelease
Scaricamento di:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [94,5 kB]
Trovato:3 http://it.archive.ubuntu.com/ubuntu xenial InRelease
Trovato:4 http://it.archive.ubuntu.com/ubuntu xenial-updates InRelease
Trovato:5 http://it.archive.ubuntu.com/ubuntu xenial-backports InRelease
Recuperati 94,5 kB in 10s (8.912 B/s)
Lettura elenco dei pacchetti... Fatto

Analysis

The APT index it’s updated again.

Input

sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual

Output

Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze
Lettura informazioni sullo stato... Fatto
linux-image-extra-4.4.0-36-generic is already the newest version (4.4.0-36.55).
È stato impostato linux-image-extra-4.4.0-36-generic per l'installazione manuale.
The following additional packages will be installed:
  linux-generic linux-headers-4.4.0-38 linux-headers-4.4.0-38-generic
  linux-headers-generic linux-image-4.4.0-38-generic
  linux-image-extra-4.4.0-38-generic linux-image-generic
Pacchetti suggeriti:
  fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools
Pacchetti raccomandati:
  thermald
I seguenti pacchetti NUOVI saranno installati:
  linux-headers-4.4.0-38 linux-headers-4.4.0-38-generic
  linux-image-4.4.0-38-generic linux-image-extra-4.4.0-38-generic
  linux-image-extra-virtual
I seguenti pacchetti saranno aggiornati:
  linux-generic linux-headers-generic linux-image-generic
3 aggiornati, 5 installati, 0 da rimuovere e 0 non aggiornati.
È necessario scaricare 68,5 MB di archivi.
Dopo quest'operazione, verranno occupati 296 MB di spazio su disco.
Continuare? [S/n] s
Scaricamento di:1 http://security.ubuntu.com/ubuntu xenial-security/main amd64 linux-image-4.4.0-38-generic amd64 4.4.0-38.57 [18,7 MB]
...
Configurazione di linux-image-generic (4.4.0.38.40)...
Configurazione di linux-headers-4.4.0-38 (4.4.0-38.57)...
Configurazione di linux-headers-4.4.0-38-generic (4.4.0-38.57)...
Configurazione di linux-headers-generic (4.4.0.38.40)...
Configurazione di linux-generic (4.4.0.38.40)...
Configurazione di linux-image-extra-virtual (4.4.0.38.40)...

Analysis

linux-image-extra-4.4.0-38-generic and linux-image-extra-virtual are now installed with all their dependencies.

Input

sudo apt-get update

Output

Basically it’s always the same…

Analysis

Updated the APT index again…

Input

sudo apt-get install docker-engine

Output

Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze
Lettura informazioni sullo stato... Fatto
The following additional packages will be installed:
  aufs-tools cgroupfs-mount git git-man liberror-perl libltdl7 patch xz-utils
Pacchetti suggeriti:
  mountall git-daemon-run | git-daemon-sysvinit git-doc git-el git-email
  git-gui gitk gitweb git-arch git-cvs git-mediawiki git-svn diffutils-doc
I seguenti pacchetti NUOVI saranno installati:
  aufs-tools cgroupfs-mount docker-engine git git-man liberror-perl libltdl7
  patch xz-utils
0 aggiornati, 9 installati, 0 da rimuovere e 0 non aggiornati.
È necessario scaricare 23,5 MB di archivi.
Dopo quest'operazione, verranno occupati 128 MB di spazio su disco.
Continuare? [S/n] s
Scaricamento di:1 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 docker-engine amd64 1.12.1-0~xenial [19,5 MB]
…
Elaborazione dei trigger per libc-bin (2.23-0ubuntu3)...
Elaborazione dei trigger per systemd (229-4ubuntu8)...
Elaborazione dei trigger per ureadahead (0.100.0-19)...

Analysis

Docker engine it’s now installed!

Input

sudo service docker start

Output

Nothing

Analysis

The docker service is started.

Input

sudo docker run hello-world

Output

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

Analysis

It works! The hello world image was run successfully!

Adding a docker group

Reference

https://docs.docker.com/engine/installation/linux/ubuntulinux/#/create-a-docker-group

Input

sudo groupadd docker

Output

groupadd: group 'docker' already exists

Analysis

I don’t need to add a docker unix group because it was created during the install.

Input

sudo usermod -aG docker $USER

Output

Nothing

Analysis

The current unix user was added to the docker unix group.
After a logging out and in again I’m able to run docker without sudo like this:

Input

docker run hello-world

Output

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

Analysis

It’s done, docker is installed 🙂