Skip to main content

Installing Docker on Debian-based Distributions

Technical
Author
Kuan-Yi Li
Table of Contents

Avoid both the use of obscure “convenience script” and the installation of out-of-tree kernel module.

Import Docker Release Key
#

sudo mkdir -m755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor --output /etc/apt/keyrings/docker-archive-keyring.gpg

Setup Docker Suite
#

Create file /etc/apt/sources.list.d/docker.list, with following distribution-specific content.

Debian
#

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian/ $(lsb_release --codename --short) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Supported architecture: amd64, armhf, arm64.

Raspberry Pi OS (32-bit)
#

The upstream of 32-bit OS is Raspbian.

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/raspbian/ $(lsb_release --codename --short) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Raspberry Pi OS (64-bit)
#

The upstream of 64-bit OS is Debian.

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian/ $(lsb_release --codename --short) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Ubuntu
#

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu/ $(lsb_release --codename --short) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Supported architecture: amd64, armhf, arm64.

Install Docker
#

Docker supports aufs storage driver and it was required on some old systems for Docker to run. Being an out-of-tree kernel module, its installation relies on DKMS and thus sometimes fails to compile or load.

But then we have overlay2, which is now the preferred storage driver, for all currently supported Linux distributions, and requires no extra configuration.

We might just install Docker without aufs—to save some space and keep ourselves away from hassle.

To do so,

sudo apt update
sudo apt-mark hold aufs-tools
sudo apt install docker-ce

References
#