Docker is a toolset to build applications and CI/CD pipelines to build, ship and run your applications in containers.
In this guide you are going to learn how to install Docker on Debian 10.
Prerequisites
A running Debian server with root privileges or a user with sudo access.
Configure Server for Docker
Login to your server using SSH and start by updating the packages to it’s latest version available.
sudo apt update
Now you can install some recommended packages to use the apt
command over HTTPS.
sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
Add the GPG key of the Docker repository to the system.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
Add the Docker repository to the APT sources.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
Update the package index with the new added Docker repository.
sudo apt update
Modify the installation to use the Docker repository instead of the default Debian repository.
apt-cache policy docker-ce
You will receive an output similar to the one below.
docker-ce: Installed: (none) Candidate: 5:19.03.13~3-0~debian-buster Version table: 5:19.03.13~3-0~debian-buster 500 500 https://download.docker.com/linux/debian buster/stable amd64 Packages
Install Docker
Once you have completed the previous steps successfully you can proceed to install Docker.
sudo apt install docker-ce
Once the installation is completed the Docker daemon has started and enabled to start on boot. To check the service is running you can use the following command.
sudo systemctl status docker
You will get an output which shows the service is active and running.
● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2020-09-17 23:43:30 UTC; 1min 15s ago Docs: https://docs.docker.com Main PID: 3687 (dockerd) Tasks: 10 Memory: 42.3M CGroup: /system.slice/docker.service └─3687 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Execute Docker command without Sudo
By now your Docker can only be run by the root user or by a user in the Docker group.
To use the docker command without sudo
you need to add your username
to the docker
group.
sudo usermod -aG docker ${USER}
For the changes to take effect you need to logout and login again.
Use the following command to confirm you are added to the Docker group.
id -nG
Output username sudo docker
Conclusion
Now you have learned how to install Docker on your Debian Busted and configured it to use without sudo.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.