Run container virtual machine by installing Docker CE on Debian 10 or 11 Bullseye Linux using the guide given here in this article…
Debian 11 is the latest long-term supported release from the developers of this Linux. However, if you are using it and don’t want to install any Virtual machine software such as Virtual Box, then Docker will be the best and lightweight platform to quickly create containers using various Linux OS and other App images.
What do you need to perform this tutorial:
- Internet connection
- Debian 11 Bullseye Linux
- A user with sudo rights
- Access to the command terminal
Docker Installation on Debian 11 Bullseye
The steps given here will also work for earlier versions of this Linux such as Debian 10 buster and other Linux based on it.
1. Install Dependencies
Few things should be there on the Debian system before installing Docker. So, first, run the system update command and then the next one to get the additional packages.
sudo apt update
sudo apt-get install apt-transport-https ca-certificates curl gnupg
2. Add Docker GPG Key
Next, add the GPG key that is necessary without it the system will generate an error after adding the repository. It is because Debian needs to verify that whatever packages we are getting to install the Docker platform are from a genuine source without any alteration using this key.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
3. Add Docker Repository on Debian 11
After adding the GPG key it’s time to manually create a repository file that holds the official Docker repo link to let the system download and install packages available through it.
Enter the whole single command in your terminal and hit the Enter key.
echo \ "deb [arch=amd64 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
4. Run system update
To let the system recognize the newly added repository, run the system update command once:
sudo apt update
5. Command to install Docker Engine on Debian 11 Bullseye
Finally, here is the command to install Docker Engine community edition, containerd, and the command line.
sudo apt-get install docker-ce docker-ce-cli containerd.io
6. Start its service, if not
Once the installation is completed you can check the status of the docker service whether it’s running normally without generating errors.
First Check status:
sudo systemctl status docker
If it is not running then, start it:
sudo systemctl start docker
Whereas to stop, if required, you can run:
sudo systemctl stop docker
To check the version:
docker --version
7. Run Docker without Sudo
By default our current user is not the part of Docker group, hence every time to run its command we have to use sudo with it. And that could be annoying for some users, hence to remove that run the below command to make your current user the part of Docker group.
sudo usermod -aG docker ${USER}
After that execute this command. It will ask for your current user password.
su - ${USER}
Basically, after adding users to a group we have to log out and log in again to the system, but we don’t need to do that lengthy process, just use the above-given command and you are done.
8. Test your Container platform
As of now we have installed and configured all the key things required to run the Docker platform on Debian 11 Bullseye. Now, let’s test whether it is working or not.
Let’s install Ubuntu Image on docker
docker pull ubuntu
To run
docker run -it ubuntu
Uninstall and Remove Docker (optional)
After some time, if you don’t require this container platform on your system, simply remove it.
sudo apt purge docker-ce docker-ce-cli containerd.io
Well, the above command will remove the platform and its components but not the downloaded app images, configuration files, and containers, they will remain there. To remove them as well, run:
sudo rm -rf /var/lib/docker sudo rm -rf /var/lib/containerd