Docker Installation

Docker Installation

In this tutorial, we will discuss about how to install docker and use it on an existing installation of Ubuntu operating system.

Docker Installation


  • Docker Engine is supported on x86_64 (or amd64), armhf, and arm64 architectures.
  • All the commands in this tutorial should be run as a non-root user. If root access is required for the command, it will be preceded by sudo.
Step 1: Uninstall old versions

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

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

When you run the above command it is OK if apt-get reports that none of these packages are installed.

The contents of /var/lib/docker/, including images, containers, volumes, and networks, are preserved. If you do not need to save your existing data, and want to start with a clean installation by running following commands.

Uninstall the Docker Engine, CLI, and Containerd packages by running following command

$ sudo apt-get purge docker-ce docker-ce-cli

Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes by running following command

$ sudo rm -rf /var/lib/docker

Please note that you must delete any edited configuration files manually.

Step 2: Get the docker script

Docker provides convenience scripts at and for installing edge and testing versions of Docker Engine – Community into development environments quickly and non-interactively.Β 

This example uses the script at to install the latest release of Docker Engine – Community on Linux. To install the latest testing version, use instead. In each of the commands below, replace each occurrence of get with test.

$ curl -fsSL -o
$ sudo sh
Step 3: Adding your user to the docker group

If you would like to use Docker as a non-root user, you should now consider adding your user to the β€œdocker” group with something like

$ sudo usermod -aG docker ashok

Here ashok is the my user. You need to change ashok to your user.

If you are facing permission denied exception then you need to run following commands

$ sudo groupadd docker

$ sudo usermod -aG docker ${USER}

$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R

$ sudo chmod g+rwx "$HOME/.docker" -R

$ sudo systemctl restart docker

$ sudo chmod 777 /var/run/docker.sock

Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running

sudo systemctl status docker

The output should be similar to the following, showing that the service is active and running:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-10-12 12:26:01 UTC; 4s ago
 Main PID: 6062 (dockerd)
    Tasks: 42
   CGroup: /system.slice/docker.service
           β”œβ”€6062 /usr/bin/dockerd -H fd://
           └─6089 docker-containerd --config /var/run/docker/containerd/containerd.toml

Installing Docker now gives you not just the Docker service (daemon) but also the docker command line utility, or the Docker client. 

Below are the links to the official Docker CE installation guides for other operating systems. You can follow these guides to install Docker on your machine, as they are simple and straightforward.

We will now run a simple container to ensure everything is working as expected. For this we need to run following command

$ docker run hello-world

This confirms us that Docker is correctly installed.

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:
Docker Installation

Scroll to top