Install and Use Docker on Ubuntu

Chandan Gupta (KeepMovingForward)
2 min readAug 29, 2023
Official Docker Image

Docker is an application that simplifies the process of managing application processes in the form of containers. Containers will let you run your applications in resource-isolated processes. They are similar to virtual machines, but containers are more portable, more resource-friendly, and more dependent on the host operating system.

First, update your existing list of packages by running the following cmd:

sudo apt update

The next step is to install a few prerequisite packages that let apt use packages over HTTPS. Run the following command to allow Ubuntu to access the Docker repositories over HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

The third step is to add the GPG Key.

A GPG key verifies the authenticity of a software package. Add the Docker repository GPG key to your system by running:

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

Step 4: Add Docker Repository to apt sources:

The following command is to add the Docker repository to apt sources:

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

Step 5: Specify Installation Source

Execute the apt-cache command to ensure the Docker installation source is the Docker repository, not the Ubuntu repository. The apt-cache command queries the package cache of the apt package manager for the Docker packages we have previously added.

apt-cache policy docker-ce

Final Step: Install Docker

sudo apt install docker-ce -y

Check Docker Status (Optional)

sudo systemctl status docker

Below Few Additional Step which is necessary in order to use docker.

Installing Docker Compose on Linux

Installing Docker Compose on Linux is a two-step process. First, you will be downloading binary from Git Hub, Second give executable permission.

Download the current stable release of Docker Compose

sudo curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Test the installation

docker-compose --version

— — — — — — — — — — — — —— — Thanks — — — — — — — — — — — — — —

--

--