• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install and Use Docker on Debian 11

Written by Admin, Updated On January 21, 2023
debian, docker
How to Install and Use Docker on Debian 11

Docker application is used to manage application processes in container. Using docker you can build, test and deploy applications that can run anywhere as portable and self-sufficient containers. In this tutorial, we will learn how to install Docker on Debian 11 Bullseye.

Prerequisites#

Before you start install, you must have non-root user account with sudo privileges.

How to Install Docker on Debian#

Follow the below given steps to install latest Docker package on Debian system:

We will install Docker from the Docker’s repositories.

Step 1 – Update Package List #

At first, update the package manager index list and upgrade the system to latest using below:

sudo apt update && sudo apt upgrade

Step 2 – Install Dependencies #

We also need to install dependencies which are required to enable Docker repository.

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Step 3 – Import GPG Key#

Now Import the GPG key for repository using following curl command:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

After that, add Docker repository to your system’s software repository list by typing:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

Step 4 – Install Docker#

Now Docker repository is enabled so update apt package manager index list again using below command:

sudo apt update

Install latest version of Docker Community Edition using below:

sudo apt install docker-ce

Once the installation completed the service of docker will start automatically. You can check it by issuing below command:

sudo systemctl status docker
● docker.service - Docker Application Container Engine
    Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
    Active: active (running) since Tue 2023-01-16 09:30:23 UTC; 12min ago
      Docs: https://docs.docker.com
  Main PID: 4485 (dockerd)
     Tasks: 8
    CGroup: /system.slice/docker.service
            └─4485 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Step 4 – Verify Installation#

At the time of writing, the latest stable version of Docker is 20.10.22. You also can check the version of Docker using below command:

docker -v
Docker version 20.10.22, build 74b1e89

Executing docker command without sudo#

By default, Docker required sudo privileges to run. If you want to run docker command without sudo then you need to add your user to docker group. The docker group is created at the installation of docker CE package.

You should run below command to add user to docker group:

sudo usermod -aG docker $USER

After that, Log out and log back in to apply membership.

Run the below command to verify that you have added docker group :

id -nG
tecnstuff sudo docker

How to Use Docker Command#

Below is the basic syntax for the docker command:

docker [option] [subcommand] [arguments]

You can get list of all docker subcommands by issuing below command:

docker

If you need any help about subcommand then you can use following command:

docker docker-subcommand --help

Upgrading Docker#

You can update docker new version when it is released. You just have to run below commands:

sudo apt update
sudo apt upgrade

Uninstalling Docker#

Uninstall process of Docker is same as any other packages installed using apt:

sudo apt purge docker-ce
sudo apt autoremove

Docker Images#

Docker containers are built from Docker Images and these are available on Docker Hub. It is a cloud-based registry service which managed by Docker Company.

Search Images#

Use search sub command to search an image on Docker Hub registry.

For example, you can search for an Debian image using below command:

docker search debian

Docker Containers#

Docker container is an instance of Docker Image. A container represents a runtime for a single application, process, or service. In simple way we can say Docker image is a class and Docker container as an instance of a class. Using docker container command we can manage operations on a container.

Start Docker Container#

Below command will start a Docker container which is an instance of an image. If you don’t have the image locally, it will download it first:

docker container run debian

In above command we have not provided any command so the container will bootup and ran an empty command and will exit at last.

You can interact with Ubuntu image using -it switch. Run below command to start an interactive container:

docker container run -it debian /bin/bash
[root@748fh3304412 /]#

As you can see above the command prompt changed. Now you can execute command and interact with Ubuntu container directly.

List Docker Containers#

You can get list of all active docker containers using below command:

docker container ls

It will list all the active containers and if no one container is running then output will be empty.

Also you can list active and inactive containers issuing below command:

docker container ls -a

Remove Docker Containers#

You can remove docker containers using container id. So just copy container id and put it after container rm in below command:

docker container rm r70023ag870r

Conclusion#

This tutorial explains how to install and use of docker on Debian 11 system. You also learned how to manage Docker containers. To learn more about Docker check out the official Docker documentation.

If you have any question or suggestion, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install MariaDB on Debian 11 Bullseye
Next Article   How to Install MongoDB on Ubuntu 22.04

Related Posts

  • How to Install WordPress with Nginx on Debian 11

    How to Install WordPress with Nginx on Debian 11

    March 22, 2023
  • How to Install MariaDB on Debian 11 Bullseye

    How to Install MariaDB on Debian 11 Bullseye

    March 8, 2023
  • How to Install PHP 8.2 on Debian 11

    How to Install PHP 8.2 on Debian 11 Linux

    February 24, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook