How to Install Docker on Ubuntu using apt repository

How to Install Docker on Ubuntu using apt repository

There are 3 methods to install Docker on Ubuntu. Below are listed three methods which we can use to install Docker on Ubuntu

  1. Install Docker on Ubuntu using the apt repository
  2. Install Docker on Ubuntu using the convenience script
  3. Install from Package

In this article we are going to check how to install docker on ubuntu using the apt repository

If you are installing Docker for the very first time on your system we have to first setup the Docker Repository. Post this we can install and update from the Docker Repository.

Below are the steps to Install Docker on Ubuntu

1) Setup the Docker Repository

  • Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg


  • Add Docker’s official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg


  • Use the following command to set up the repository:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


2) Install Docker Engine

  • Update the apt package index:
sudo apt-get update


  • Install Docker Engine, containerd, and Docker Compose.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin


  • Verify that the Docker Engine installation is successful by running the hello-world image.
sudo docker run hello-world


Using above command downloads a test image and runs it in a docker container. When the container runs, it prints a confirmation message and exits.

You have now successfully installed and started Docker on Ubuntu.

You can check other methods to install Docker On Ubuntu as follows:

  1. How To Install Docker On Ubuntu Using The Convenience Script
  2. How To Install Docker On Ubuntu Using Package


Happy Coding!

🔥 66 Views
Jul 21, 2023

How to create a folder in Docker

To create a folder in docker or a file create a directory for the build context and cd into it. You can use the classic mkdir command to create a folder in Docker.

🔥 10.6K Views
Apr 6, 2022

Create Directory if not Exists in DockerFile

To create a Directory that does not exist you have to use the --p command along with the mkdir command. Becausemkdir isn't recursive by default -- it expects the immediate parent directory to exist.

🔥 10.2K Views
Apr 6, 2022

Dockerfile mkdir permission denied

Docker Filesystems and Docker containers work in a similar manner to filesystems outside a Docker container. To provide users read/write/execute permissions use this command chmod 0777 /usr/local/docker/foo

🔥 7.6K Views
Apr 6, 2022

Async Await in Do While Loop

In this post, we are going to checkout Async Await in Do while loop with examples. Do while Loop in Typescript is same as the Do While Loop in Javascript.

🔥 2.6K Views
Sep 2, 2022

Create Canvas Dynamically in Angular

We can use Renderer API to create canvas dynamically in Angular which can be imported from angular/core package. Renderer API allows DOM maniplulation.

🔥 1.7K Views
Dec 10, 2022

Adding a script to an Angular Library

Adding External Scripts in Angular Library or application. You can add external scripts in angular application on runtime using javascript with few lines of code.

🔥 792 Views
Mar 18, 2022

Indian Currency Pipe in Angular

Indian currency pipe in Angular, Currency pipe angular without symbol, Angular Currency Pipe is one of the built in pipe in Angular used to format currency value according to given country code,currency,decimal,locale information.

🔥 692 Views
Aug 29, 2022

Docker mkdir permission denied Mac

Docker mkdir permission Failed ? For using data volumes in Docker by command-line and If your Docker host is on the Linux platform, you can find Docker volumes by /var/lib/docker/volumes path.

🔥 608 Views
Apr 7, 2022

Repository is not clean. Please commit or stash any changes before updating

Repository is not clean. Please commit or stash any changes before updating. If you are getting such kind of Error use the --force flag along with the ng update command

🔥 521 Views
Apr 15, 2022

Uninstall angular cli using yarn

To uninstall any package using yarn you have to use the "remove" keyword along with the package name. You can also add in "global" keyword to uninstall the package globally using yarn from your system.

🔥 441 Views
Dec 6, 2022