• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SMASHING LAB

GUIDES | LINUX | GEEKY STUFF

  • Nginx
  • Linux
  • Guide
  • Ubuntu
  • WordPress
  • Drones, My Hobby

Install Docker on Ubuntu 16.04 Xenial Xerus

By Imran Yousaf

In this tutorial, we will see how to install the official version of Docker on Ubuntu 16.04 Xenial Xerus in a simple and fast way.

Included in Ubuntu 16.04 Xenial Xerus is already available version 1.6.1 of Docker packaged for deployment, but in this article, we will find out how to install the version available on the docker.com site that is up to date.

Ubuntu Xenial installation is pretty easy: the first thing to do is update the list of packages in your distribution.

1
apt-get update

Then add Docker’s repository key to your operating system.

1
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add official stable Docker repositories.

1
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

update the system by issuing the following command,

1
sudo apt-get update

Make sure docker official repositories are added and used instead of default Ubuntu.

1
sudo apt-cache policy docker-ce

You will receive following output whcih shows that official resposatories are used for docker,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mani@host:~$ apt-cache policy docker-ce
docker-ce:
Installed: (none)
Candidate: 17.06.2~ce-0~ubuntu
Version table:
17.06.2~ce-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
17.06.1~ce-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
17.06.0~ce-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
17.03.2~ce-0~ubuntu-xenial 500
500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
17.03.1~ce-0~ubuntu-xenial 500
500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
17.03.0~ce-0~ubuntu-xenial 500
500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

Now we install Docker

1
sudo apt-get install -y docker-ce

At this point docker group automatically added to our system. All you need to add your desired user with sudo power to run the docker without typing sudo every time. Change “mani” with your username.

1
sudo usermod -aG docker mani

Activate OverlayFS for Docker on Ubuntu 16.04 Xenial Xerus

This step is completely optional but allows you to use Docker with a different driver and file system than the standard ones.

If you wish, you can use a different disk for Docker images and containers. Suppose you want to keep the root filesystem separate from the image files and containers.

Prepare the new disk by creating a new partition by replacing sdb with the device you decided to allocate to Docker:

1
sudo fdisk /dev/sdb

Once you’ve created the partition, format it with the ext4 format.

1
sudo mkfs -t ext4/dev/sdb1

We create the /var/lib/docker/overlay folder

1
sudo mkdir -p /var/lib/docker/overlay

Now insert in the /etc/fstab file the necessary information for the disk to be mounted in the folder at each reboot of Ubuntu 16.04.

1
sudo nano /etc/fstab

Add the line

1
/dev/sdb1/var/lib/dockers/overlay ext4 defaults, nofail 0 2

Let’s remember to replace /dev/sdb1 with the partition created for Docker or with the UUID assigned to that partition. You can find out the UUID using the command:

1
sudo blkid

I show you how my file /etc/fstab was made after editing:

At this point, we mount the file system.

1
sudo mount -a

Then open the /etc/default/docker file to indicate that you use overlay and custom folder.

1
sudo nano /etc/default/docker

Insert the following line at the bottom of the file:

1
DOCKER_OPTS = "- s Overlay -g /var/lib/docker/overlay"

We save the file.

Let’s restart Docker.

1
sudo service docker restart

Some more articles you might also be interested in …

  • How to Install Brackets on Debian / Ubuntu
  • Guide How to Install Apache in Ubuntu 18.04
  • Complete Guide: How To Install Ubuntu Server 18.04
  • How to Install LAMP Stack (Linux, Apache, MySQL,…
  • How to install LAMP on CentOS 8
  • How to install Nextcloud on CentOS 8
  • How to install Zabbix on openSUSE Leap 15.1
  • How to Install LAMP on openSUSE Leap 15.1
  • How to Install and Secure phpMyAdmin with Apache on…
  • Install LEMP Stack (Nginx, MariaDB, PHP-FPM) on…
Tweet
Pin
Share
0 Shares

Filed Under: Guide, Ubuntu

Primary Sidebar

  • Twitter
  • Facebook
  • Google+

Recent Posts

  • How to install Nextcloud on CentOS 8
  • How to install Zabbix on openSUSE Leap 15.1
  • How to Easily Configure Your Domain’s Email Account with Gmail?
  • Tails 4.4 OS Released with Tor Browser 9.0.6
  • How to Convert JPG to PDF in Linux

Subscribe to our Newsletter

Useful articles, tips and videos about creating and promoting websites to your mail



* required field


  • Contact Us
  • Privacy Policy
  • About Us

Copyright © 2021. Smashing Lab