how to install docker to Ubuntu

How to install docker to Ubuntu

To install Docker Engine - Community, you need the 64-bit version of one of these Ubuntu versions:

Disco 19.04

Cosmic 18.10

Bionic 18.04 (LTS)

Xenial 16.04 (LTS)

To check the verion of your Ubuntu system,by

$sudo lsb_release -a

Uninstall old versions
Older versions of Docker were called docker, docker.io , or docker-engine. If these are installed, uninstall them:

$ sudo apt-get remove docker docker-engine docker.io containerd runc

Install Docker Engine - Community

SET UP THE REPOSITORY

Update the apt package index:

$ sudo apt-get update

Install packages to allow apt to use a repository over HTTPS:

$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

Add Docker’s official GPG key:

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

Verify that you now have the key with the fingerprint

9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

by searching for the last 8 characters of the fingerprint.

$ sudo apt-key fingerprint 0EBFCD88

pub   rsa4096 2017-02-22 [SCEA]
  9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

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

INSTALL DOCKER ENGINE - COMMUNITY

Update the apt package index.

$ sudo apt-get update

Install the latest version of Docker Engine - Community and containerd, or go to the next step to install a specific version:

$ sudo apt-get install docker-ce docker-ce-cli containerd.io

List the versions available in your repo:

$ apt-cache madison docker-ce

However,if you don’t want to choose, just use $ sudo apt-get install docker-ce would install the latest version

Verify that Docker Engine - Community is installed correctly by running the hello-world image.

$ sudo docker run hello-world

Enjoy