Install Docker and docker-compose on Debian 10
30 Aug 2020Docker is awesome to quickly get a service up an running. Installing Docker on Debian 10 is not just apt-get install docker
There is an official guide over at docs.docker.com but it uses curl
which is not installed by default in Debian 10. And I like to install as few packages as I can, so I am using wget
instead of curl
.
Dependencies for installing Docker
First we need to install some dependencies to be able to use a repo over https
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates gnupg-agent
Add Docker repo and GPG key the GPG key using wget
First download the GPG key from docker.com
wget -q https://download.docker.com/linux/debian/gpg -O- | sudo apt-key add -
and then add the Docker repo
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
Install Docker & docker-compose
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose
Allow user to use Docker
To let your normal user to run docker commands you need to add the user to the docker group
sudo usermod -aG docker <username>
All in one script
#!/bin/bash
#
# Docker & docker-compose install script
# By Raddinox (https://blog.raddinox.com)
#
if [[ $EUID -ne 0 ]]; then
echo "Run as super user"
exec sudo /bin/bash "$0" "$@"
exit
fi
echo "Installing Docker..."
apt-get install -y apt-transport-https ca-certificates gnupg-agent
wget -q https://download.docker.com/linux/debian/gpg -O- | apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose