Install docker on Debian

While Debian repository itself provides Docker package, it is best recommended to install it using Docker’s own repository. In this article, we’re going to learn how to install Docker & Docker Compose on Debian 10, 12 or 13. Make sure to uninstall old Docker before starting with this article.

Setting up repository

To install docker properly, you need to attach your VPS/VM/BM with Docker repository. Run the following set of commands to do it:

# Add Docker's official GPG key:
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/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

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

This will update your apt packages, install basic stuff needed to pull necessary info to add repo, add necessary keys for docker, gather your OS info and automatically determine which version of repository to put in place. For example, if you have bookworm installed, it will automatically put bookworm in place.

Installing Docker & Docker Compose

Here are the straight forward commands that will install Docker and Docker Compose for you.

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

Conclusion

That’s pretty much it. You have successfully installed Docker. Why did I choose this way to install over Debian’s built in repo? Mainly because I can’t be arsed to do docker-compose and do docker compose on the other. This also allows better compatibility with docker’s latest features and other cool stuff that comes along with it rather than waiting for Debian’s repo pipeline. You can find this in Docker’s official documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *