Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 12 - Install Docker

Related Posts

Steps

Run the following script to install docker on Debian 12.

#!/bin/bash

# Update the apt package index and install packages to allow apt to use a repository over HTTPS
sudo apt update

sudo apt install -y \
  apt-transport-https \
  ca-certificates \
  curl \
  gnupg-agent \
  software-properties-common

# Add Docker's official GPG key and add read permission to everyone.
sudo curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

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

# Install docker  with the docker compose and the buildx plugin.
# More info on buildx here: https://github.com/docker/buildx
sudo apt update && \
  sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Add yourself to the docker group so you can run docker commands
# without sudo
sudo adduser $USER docker

At the time of writing this post, this resulted in installing Docker version 24.0.2.

References

Last updated: 20th October 2023
First published: 26th June 2023

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch