Development notes

Thoughts, notes and ideas about development

How to install Docker on Ubuntu 16.04

2016-12-10 3 min read Development Alexey Bogdanov

Introduction

Docker is software containerization platform which makes it easier to create, deploy, and run applications by using containers. It’s the most popular containerization platform in our days. More details about Docker could be found on Docker official web site or Wikipedia.

This tutorial describes only how to install Docker on Ubuntu 16.04. Installation process on other distribution looks very similar but can have some differences. How to use Docker will be described into future tutorials.

Before Installation

All listed commands below should be run in terminal (console) by user with sudo privileges. To install/remove packages I prefer to use aptitude (is not installed by default anymore on Ubuntu) command instead of apt-get. In case when aptitude is not installed or for some other reasons apt-get can be used. (apt-get installed by default on Ubuntu)

In this tutorial we will install Docker form Docker repositories, not from Ubuntu repositories.

Update packages

Before installing any new package on Ubuntu it’s better to have up to date system. It will allow us to avoid issues with package dependencies and errors during installation. To update packages and upgrade system:

sudo aptitide update && sudo aptitude upgrade

Add Docker repository

First of all we need to add GPG key for Docker repository:

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

Now we can add Docker repository:

sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'

Install Docker

To install Docker we need to update packages and install docker-engine package:

sudo aptitude update && sudo aptitude install docker-engine

Verify Docker installation

Now we need to verify that Docker works properly. First of all we need to verify the status of Docker service:

sudo systemctl status docker

The output will look into the following way:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2016-12-10 17:47:22 +03; 5h 40min ago
     Docs: https://docs.docker.com
 Main PID: 1105 (dockerd)
    Tasks: 45
   Memory: 278.3M
      CPU: 26.174s
   CGroup: /system.slice/docker.service

To verify installed Docker version:

sudo docker version

The output will look into the following way:

Client:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 22:01:48 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 22:01:48 2016
 OS/Arch:      linux/amd64

As you probably notices the previous command (version verification) is run with sudo privileges. To run Docker commands without sudo we need to add our user (or user who will run docker commands) to the docker group into the following way:

sudo usermod -aG docker $(whoami)

$(whoami) prints current user. To add another user to docker group $(whoami) should be replaced by username.

comments powered by Disqus