In this tutorial we will try to install Docker on Ubuntu-18.04. we will also download a Docker image and then create a container out of it.

Step 1 : Uninstall any previous version of Docker

sudo apt-get remove docker docker-engine containerd runc

Step 2 : Update the Ubuntu Repository

  • In this step we will update the Ubuntu repository such that the apt-get command can install docker from its repository
sudo apt-get update
  • Install the dependencies needed for Docker installation
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
  • Add Docker’s official GPG key and update the repository
curl -fsSL | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] \
   $(lsb_release -cs) \

Step 3 : Install Docker

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli

Step 4 : Update the permission of docker socket

sudo chmod 777 /var/run/docker.sock

Verify Docker Installation

  • we will check the docker version
docker version
  • You will get output like below. The contents may be different based on the docker version that you have installed
Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:45:36 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:44:07 2020
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
  Version:          0.18.0
  GitCommit:        fec3683

Check status of docker service

  • You can check if docker is running or not
 systemctl status docker

Start docker service

  • If the docker service is not running then you can start the docker service using
 systemctl start docker

Stop docker service

  • You can stop the docker service
 systemctl stop docker

Create a Ngnix Docker Container

docker run --name selftuts-nginx -d nginx
  • This will download the nginx docker image from docker-hub
  • Then it will create a docker container
  • You can run the below command to check if container is up and running
docker ps
  • This will give below output
selftuts@node1:~$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
2e72c0c104ab        nginx               "/docker-entrypoint.…"   4 seconds ago       Up 2 seconds        80/tcp              selftuts-nginx

Happy Coding

4 1 vote
Article Rating
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
11 months ago

[…] Docker must be installed Install Docker on Ubuntu 18.04 […]

Would love your thoughts, please comment.x