Installing Docker on Debian 10

29/12/2020
In this article, I am going to show you how to install the latest Docker CE (Community Edition) on Debian 10 Buster. So, let’s get started.

Installing Required Dependencies:

First, you have to install some dependency packages on Debian 10. All of these packages are available in the official package repository of Debian 10.

Now, update the APT package repository cache with the following command:

$ sudo apt update

The APT package repository cache should be updated.

Now, install all the required packages with the following command:

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

Now, press Y and then press <Enter> to confirm the installation.

All the required dependency packages should be installed.

Adding Docker Package Repository:

Now, Docker uses HTTPS protocol to serve the Docker packages over the internet. So, you must add the GPG key of the Docker package repository in order to use it.

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

The GPG key should be added.

Now, run the following command to add the Docker package repository to your Debian 10 machine.

$ echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs)
stable"
| sudo tee /etc/apt/sources.list.d/docker-ce.list

The Docker package repository should be added.

Now, update the APT package repository cache with the following command:

$ sudo apt update

APT package repository cache should be added.

Installing Docker:

Now, install Docker CE with the following command:

$ sudo apt install docker-ce docker-ce-cli containerd.io

Now, to confirm the installation, press Y and then press <Enter>.

The APT package manager will download and install all the required packages.

At this point Docker CE should be installed.

Now, add your login user to the docker group with the following command:

$ sudo usermod -aG docker $(whoami)

Now, restart your computer with the following command:

$ sudo reboot

Once your computer starts, run the following command to check whether Docker is working correctly.

$ docker version

As you can see, everything is working great. At the time of this writing, Docker CE 19.03.1 is the latest version of Docker Community Edition.

Docker Basics:

In this section, I am going to show you how to use Docker to set up a basic HTTP web server. This way, you will learn,

  • how to search Docker images
  • how to download Docker images
  • how to list local Docker images
  • how to use Docker images to create containers
  • how to list Docker containers
  • how to stop and remove Docker containers

Let’s say, you want to host your static webpages on a Docker container. To do that, you need an HTTP server Docker image.

To search for a http server Docker image, run the following command:

$ docker search ‘http server’

As you can see, a lot of Docker images are listed in the search result. Here, NAME column contains the name of the Docker image, DESCRIPTION column contains a short description of the Docker image, the STARS column represents how popular that Docker image is, the OFFICIAL column if [OK] it means the Docker image is officially maintained by the company/organization responsible for the product/service.

Now, let’s say, you like the Apache HTTP Server. The NAME of the Docker image is httpd.

To download the httpd Docker image, you can run the following command:

$ docker pull httpd

As you can see, Docker is downloading the httpd image from the internet.

At this point, the Docker image is downloaded.

When a Docker image is downloaded for the first time, it is cached on the local filesystem. So, when you use it later, you won’t have to re download the same Docker image. Thus, it saves you a lot of time and bandwidth.

You can list all the local cached Docker images with the following command:

$ docker image list

As you can see, the Docker image httpd is cached locally.

Now, let’s say, you have a directory website/ on your users HOME directory where all your html project files are.

Now, you can tell Docker to create a container from the httpd image, run the container, map the $HOME/website directory to the webroot (/usr/local/apache2/htdocs) of the httpd container and forward the port 80 of the container to the port 8080 of your computer with the following command:

$ docker run -d -v $HOME/website:/usr/local/apache2/htdocs -p 8080:80 httpd

A new container should be created.

Now, go to a web browser and visit http://localhost:8080

As you can see, the httpd Docker container is serving webpages from the mapped directory $HOME/website

You can list all the running containers with the following command:

$ docker container ls

As you can see, I have only one running container at the moment. You can find CONTAINER ID, IMAGE, STATUS, PORTS, NAMES etc. of each of the running containers from here. The most important one is the NAMES of the containers. Here, the name is randomly generated as I haven’t specified any when I created the container. The name in my case is vigorous_bardeen. Remember the name of your container as you will need it shortly.

Now, if you want to stop the container vigorous_bardeen, run the following command:

$ docker container stop vigorous_bardeen

You can also start a stopped container (let’s say vigorous_bardeen) with the following command:

$ docker container start vigorous_bardeen

If you need to restart a container (let’s say vigorous_bardeen), you can run the following command:

$ docker container restart vigorous_bardeen

If you want to permanently remove a container (let’s say vigorous_bardeen), you can run the following command:

$ docker container rm vigorous_bardeen

So, that’s how you install Docker on Debian 10 and use Docker. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Docker Image vs Container

Understanding the process Docker uses to store data through images and containers will help you better design your Docker...
28/12/2020

Understanding The Dockerfile

You’ll agree with me that the impact Docker is having on the world of technology is massive. It is saving software developers...
29/12/2020

LXD vs Docker

Not everything new is good and not everything revolutionary is necessary. With container technologies, like with every other...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao ở đâu?
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024