Watch all our Tutorials and Training Videos for Free on our Youtube Channel, Get Online Web Tools for Free on swebtools.com

Search Suggest

How to Install Docker on Ubuntu 18.04 - Docker Tutorial

install docker on ubuntu, docker installation on ubuntu, docker tutorial, docker installation ubuntu, install docker commands, docker cli install
This tutorial post will show you How to Install Docker on Ubuntu 18.04 with step by step procedure. End of this post, you will be able to understand how to install docker on Ubuntu 18.04.

Steps involved in this Docker Installation,
1. How to enable repository for docker?
2. How to Deploy Docker’s official GPG key?
3. How to Install Docker using apt-get command?
4. How to Verify Docker information?In the previous posts, already we have explained the below topics. Refer those links to understand this topic from basics.

What is Docker - Get Started from Basics - Docker Tutorial
What is Container, What is Docker on Container - Get Started
How to Install Docker on CentOS 7 / RHEL 7
Docker Images Explained with Examples - Docker Tutorial
Dockerfile Instructions Explained with Examples
How to Write Dockerfile To Build Your Own Docker Images
Docker ONBUILD Command Explained with Examples
Docker ARG vs ENV Command Differences Explained in Detail
Docker CMD & ENTRYPOINT Differences Explained in Detail

How to Install Docker on Ubuntu 18.04

Lets get started.

How to Install Docker on Ubuntu 18.04

1. How to enable repository for docker?

On Ubuntu 18.04:
Before installing docker on ubuntu, update the packages index using the 'apt-get update' command as below.

sudo apt-get update

Output:
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists... Done

Once you have updated your packages index, lets deploy the Docker’s official GPG key and install Docker.

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

Output:
OK

Now, enable the repository.

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

Output:
Get:1 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:3 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [2,033 B]
Hit:4 http://archive.ubuntu.com/ubuntu bionic-security InRelease
Hit:5 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Fetched 66.5 kB in 1s (97.1 kB/s)
Reading package lists... Done

2. How to Install Docker on Ubuntu 18.04?

Use "apt-get install" command to install docker with required dependencies automatically.

sudo apt-get install docker.io

Output:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
bridge-utils cgroupfs-mount ubuntu-fan
Suggested packages:
aufs-tools debootstrap docker-doc rinse zfs-fuse | zfsutils
The following NEW packages will be installed:
bridge-utils cgroupfs-mount docker.io ubuntu-fan
0 upgraded, 4 newly installed, 0 to remove and 55 not upgraded.
Need to get 30.1 MB of archives.
After this operation, 137 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 bridge-utils amd64 1.5-15ubuntu1 [30.1 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 cgroupfs-mount all 1.4 [6,320 B]
Get:3 http://archive.ubuntu.com/ubuntu bionic/universe amd64 docker.io amd64 17.12.1-0ubuntu1 [30.1 MB]
Get:4 http://archive.ubuntu.com/ubuntu bionic/main amd64 ubuntu-fan all 0.12.10 [34.7 kB]
Fetched 30.1 MB in 33s (924 kB/s)
Preconfiguring packages ...
Selecting previously unselected package bridge-utils.
(Reading database ... 174991 files and directories currently installed.)
Preparing to unpack .../bridge-utils_1.5-15ubuntu1_amd64.deb ...
Unpacking bridge-utils (1.5-15ubuntu1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../cgroupfs-mount_1.4_all.deb ...
Unpacking cgroupfs-mount (1.4) ...
Selecting previously unselected package docker.io.
Preparing to unpack .../docker.io_17.12.1-0ubuntu1_amd64.deb ...
Unpacking docker.io (17.12.1-0ubuntu1) ...
Selecting previously unselected package ubuntu-fan.
Preparing to unpack .../ubuntu-fan_0.12.10_all.deb ...
Unpacking ubuntu-fan (0.12.10) ...
Setting up docker.io (17.12.1-0ubuntu1) ...
Adding group `docker' (GID 128) ...
Done.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket â /lib/systemd/system/docker.socket.
Processing triggers for ureadahead (0.100.0-20) ...
Setting up cgroupfs-mount (1.4) ...
Setting up bridge-utils (1.5-15ubuntu1) ...
Setting up ubuntu-fan (0.12.10) ...
Created symlink /etc/systemd/system/multi-user.target.wants/ubuntu-fan.service â /lib/systemd/system/ubuntu-fan.service.
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2) ...
Processing triggers for ureadahead (0.100.0-20) ...

We have successfully installed docker as expected. Lets verify the docker information.

4. How to Verify Docker information?

Use below docker command with "-v" option to know the docker package version with build release information.

docker -v

Output:

Docker version 17.12.1-ce, build 7390fc6

Also we can use "version" argument along with docker command to know the relevant information about the docker package.

sudo docker version

Output:

Client:
Version:       17.12.1-ce
API version:   1.35
Go version:    go1.10.1
Git commit:    7390fc6
Built: Wed Apr 18 01:23:11 2018
OS/Arch:       linux/amd64
Server:
Engine:
Version:      17.12.1-ce
API version:  1.35 (minimum version 1.12)
Go version:   go1.10.1
Git commit:   7390fc6
Built:        Wed Feb 28 17:46:05 2018
OS/Arch:      linux/amd64
Experimental: false


That's all about the Installation of Docker on Ubuntu 18.04, Its pretty straight forward. Hope you have got an idea how to install docker on Ubuntu. Going forward, we will play more with docker tool.
If you are interested in learning, Request you to go through the below recommended tutorial.