Skip to main content

Installing Docker and Docker Compose on Debian 12

Before installing Docker, ensure your Debian system is up-to-date with the following command:


sudo apt update && sudo apt upgrade -y

Shell

Once your system is updated, install the necessary packages to allow apt to use a repository over HTTPS:


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

Shell

Next, add the official GPG key of Docker:


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

Shell

Add the Docker repository to APT sources:


echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Shell

Update your package index and install Docker CE (Community Edition):


sudo apt update && sudo apt install docker-ce -y

Shell

To ensure Docker starts on boot, use the following command:


sudo systemctl enable docker

Shell

Verify the Docker installation by running the hello-world image:


sudo docker run hello-world

Shell

Installing Docker Compose on Debian 12

Docker Compose is a tool for defining and running multi-container Docker applications. To install Docker Compose, first, download the latest version from the official GitHub repository:


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

Shell

Next, set the appropriate permissions to make the binary executable:


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

Shell

Verify the installation by checking the version of Docker Compose:


docker-compose --version

Shell

At this point, Docker and Docker Compose are installed and ready for use on your Debian 12 system.