Passion's Log

Where code meets life

← Back to blog

Installing Docker and Docker Compose on Ubuntu

Docker has become standard infrastructure for modern development and deployment. This guide provides a standardized installation process for Docker and Docker Compose to ensure a stable, reproducible, and maintainable environment.

DevOps #DevOps#Docker#Ubuntu#Containerization#System Administration#CI/CD#Automation

Introduction

Docker has become the standard infrastructure for modern development and deployment, used to achieve environment consistency and rapid delivery.

However, in practical use, issues such as chaotic installation methods, inconsistent versions, and non-standard Compose management remain common.

This article will provide a standardized Docker and Docker Compose installation process from scratch, ensuring the environment is stable, reproducible, and maintainable.


Prerequisites

Update Ubuntu

sudo apt update && sudo apt upgrade -y

Add Docker Repository

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

Add Docker Official GPG Key

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

Add Docker Official Repository

echo "deb [arch=$(dpkg --print-architecture) 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

Update Ubuntu Source List

sudo apt update

Install Latest Version of Docker

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

Start Docker Service

sudo systemctl start docker

Configure Docker to Start on Boot

sudo systemctl enable docker

Verify Docker Service Status

sudo systemctl status docker

Check Installed Docker Version

sudo docker version

Install Docker Compose

Method 1

Install Docker Compose Using Binary

Download Latest Docker Compose

https://github.com/docker/compose/releases

Install Latest Stable Docker Compose Binary

At the time of writing, the latest version is v2.40.3.

If there is a newer version, simply replace v2.40.3 in the command above with the latest version number. Do not forget the ‘v’ before the number.

sudo curl -L "https://github.com/docker/compose/releases/download/v2.40.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Finally, Grant Execute Permissions to the Binary

sudo chmod +x /usr/local/bin/docker-compose

Check Installed Docker Compose Version

sudo docker-compose version

Method 2

Install Docker Compose Using pip

# Refer to my previous link for pip installation

After installing pip, run the following command to install Docker Compose.

pip install docker-compose

Check Docker Compose Version

docker-compose --version

Comments

Back to top