Docker is an open platform tool which provides container run time environment. With the help of docker, developers can build, ship and run their code as a container anywhere like on-prem or public cloud. Docker makes use of OS-level virtualization to spin up the containers. The host on which docker is installed and containers are spun are called as ‘Docker Engine’.
In this post, we will cover how to install Docker Engine (Community Edition) on Debian 11 (Bullseye) step by step.
Prerequisite of Docker
- Minimal Debian 11 Installation
- 64-bit System
- Stable Internet Connection
- User with sudo rights
Let’s jump into the installation steps of Docker on Debian 11
Step 1) Update Package Index and Install dependencies
Login to Debian 11 system, open the terminal and run below command to update package index
$ sudo apt update
Now, run below apt command to install docker dependencies,
$ sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release -y
Step 2) Configure Docker Repository
To configure docker repository, let’s first add Docker’s GPG key via following curl command.
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Execute below echo command to configure official docker repository.
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Output of above command,
Step 3) Install Docker Engine
Run the following apt commands to install docker engine,
$ sudo apt update $ sudo apt -y install docker-ce docker-ce-cli containerd.io
Output of above apt commands would look like below,
Once the docker is installed successfully, verify its version and service status by running,
$ sudo docker version
$ sudo systemctl status docker
Above output confirm that, docker service is up and running. In case docker service is not running then try to start its service using beneath command.
$ sudo systemctl start docker
Step 4) Verify Docker Installation
To verify the docker installation, try to spin up ‘hello-world’ container and see whether informational message is displayed or not.
To spin up ‘hello-world’ container, run below docker command with sudo
$ sudo docker run hello-world
Above informational message confirms that docker is installed and working properly.
Step 5) Allow Local User to Run Docker Command
To allow local user to run docker commands without sudo, add the user to docker group (secondary group) using usermod command.
$ sudo usermod -aG docker linuxtechi
Note: Replace the username in above command as per your setup and also don’t forget to logout & login to make the changes into the effect.
Removal of Docker Engine
In case you are done with docker testing and want to remove docker from your system then run following commands to uninstall it,
$ sudo apt purge -y docker-ce docker-ce-cli containerd.io $ sudo rm -rf /var/lib/docker $ sudo rm -rf /var/lib/containerd
That’s all from this post, please do share your feedback and queries in the below comments section.