Back to blogs

Installing Docker on Linux Systems (Ubuntu)

Docker is an awesome tool for deploying your application to a different platform. In this article, let us install the Docker Community Edition on our local machines for testing this deployment

This guide is mainly to install Docker CE. Also in case you want to install multiple versions of Docker, better follow the official guide ⬆.

Uninstall the Old Version

Make sure you don't have any other version already installed on the machine.

Code specimenshell
sudo apt-get remove docker docker-engine docker.io containerd runc
Preparing syntax

Adding docker Official Repository to APT index

By default, apt does not support Docker to be installed/updated since apt is not aware of the official Docker Repository. In order to add the same.

First, Update apt package index.

Code specimenshell
sudo apt-get update && sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
Preparing syntax

Add Docker’s official GPG key:

Code specimenshell
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Preparing syntax

Set up a stable repository.

Code specimenshell
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Preparing syntax

Installing Docker-Engine

Update apt index to latest and install ?Docker Engine

Code specimenshell
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io
Preparing syntax

You should now have Docker installed in your machine.

To check the same.

Code specimenshell
sudo docker run hello-world
Preparing syntax

You should now get a response like:

⭐ You might have observed that we used sudo along with docker run to deploy our image to container. This is because no user has been yet added to our Docker group.

Add Current User to Docker Group

Execute the below command to do so:

Code specimenshell
usermod -a -G docker $USER
Preparing syntax

⚠ You need to restart the machine (log out & log back in) for the changes to take effect.