How to install Docker and Docker Compose on Ubuntu LTS 22.04

Shaon Majumder
2 min readMar 11, 2024

--

In today’s world of software development and deployment, efficiency and consistency are paramount. This is where containerization comes into play, and Docker is one of the most popular tools for creating and managing containers. In this guide, we’ll walk through the process of installing Docker and Docker Compose on Ubuntu LTS 22.04, enabling you to harness the power of containerization for your projects.

Installing Docker on Ubuntu LTS 22.04

Before diving into the installation process, it’s essential to ensure that conflicting packages are removed to prevent any potential issues. Run the following command to uninstall conflicting packages:

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

Now that conflicting packages are removed let’s proceed with the installation of Docker.

Setting up Docker’s apt repository

  1. Add Docker’s official GPG key and necessary dependencies:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

2. Add the Docker repository to Apt sources:

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Installing Docker packages

Now that the repository is added, proceed with installing Docker packages:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Verifying the installation

To ensure that Docker Engine is installed successfully, run the following command:

sudo docker run hello-world

If Docker Engine is installed correctly, you’ll see a message confirming the successful installation.

Installing Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications. Installing Docker Compose on Ubuntu LTS 22.04 is straightforward.

sudo apt install docker-compose

With this command, Docker Compose will be installed and ready to use.

Conclusion

By following the steps outlined in this guide, you’ve successfully installed Docker and Docker Compose on Ubuntu LTS 22.04. With Docker, you can create, deploy, and manage containers efficiently, streamlining your development and deployment processes. Additionally, Docker Compose empowers you to define and run multi-container Docker applications with ease. Now, you’re equipped with powerful tools to take your projects to the next level using containerization.

--

--