Installing Docker & Docker Compose V2 Plugin on Debian Based Systems
A

Lead Engineer @ Packetware

Installing Docker & Docker Compose V2 Plugin on Debian Based Systems

Step 1: Add Docker GPG Key and Repos

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
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

# Add the repository to Apt sources:
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
sudo apt-get update

Step 2: Install Docker

Before you begin, make sure your system packages are up to date. Open your terminal and run the command:

sudo apt update && sudo apt install docker.io -y

This command performs two actions. Firstly, sudo apt update refreshes the list of available packages and their versions, but it does not install or upgrade any packages. Secondly, sudo apt install docker.io -y installs the Docker engine on your system. The -y flag automatically answers "yes" to any prompts, ensuring a smooth installation process.

Step 3: Install Docker Compose

With Docker installed, the next step is to install Docker Compose. On Debian-based systems, Docker Compose can be installed via the docker-compose-plugin package. Run the following command:

sudo apt install docker-compose-plugin -y

This command installs the Docker Compose plugin, which you can now use to manage multi-container Docker applications using the Compose file format.

Verification

To confirm that Docker is installed correctly, run:

docker --version

This command should return the version number of Docker installed on your system. Similarly, check the Docker Compose plugin by running:

docker compose version

This should display the version number of the Docker Compose plugin. With these two simple commands, you're now equipped with Docker and Docker Compose on your Debian-based system. This setup will allow you to create, deploy, and manage containerized applications efficiently, leveraging the robust features provided by the Docker ecosystem. Whether you're developing locally or deploying to the cloud, Docker and Docker Compose enhance your ability to build scalable applications.