[Cloud Native-Docker Chapter] Introduction to Docker

Hits: 0

Directory Navigation


I wrote a few articles about [Docker] for cloud natives , but I found that I didn’t write an introductory article about Docker, so I’ll make it up, hoping to help more comrades who are just getting started with Docker.

1. Introduction of Container 3W

1.1 What is a container

A container is a lightweight, portable, self-contained software packaging technology that enables an application and the supporting environment it needs to be packaged together to run the same way almost anywhere.

1.2 Why do we need containers

For developers: Build Once, Run Anywhere

For operation and maintenance personnel: Configure Once, Run Anywhere (configure once, run anywhere)

1.3 How containers work

The main architecture of Docker includes the following elements:

  • Client, the client includes various forms. In addition to the commonly used Docker command line, it can also be in the form of REST API. The function of the client is to send instructions to the Docker Host to perform a series of operations. The Client can run on the same or different machine as the Docker Host.
  • Docker Host:
    • Docker Daemon, the daemon thread of Docker, performs specific operations on containers and images by accepting instructions from Client. By default, only the Client directive of the local Host is accepted.
    • Image, the image is read-only. It is produced locally or pulled from the Registry. It is used to generate one or more container instances and is the template of the container.
    • Container, the container instance, runs through the image, any modification to the container will not affect the image, and it is the container instance that really provides services to the outside world.
  • Registry, a mirror repository, can be built locally. It is usually recommended to use the mirror repository of a major domestic manufacturer, or use the official DockHub mirror repository.

The relationship between them can be represented by the following diagram:

Docker Architecture Diagram
A complete workflow is as follows:

  1. Open the Docker Client client and connect to the Docker Host;
  2. Pull the image from the Registry to the local through the docker pull command;
  3. Run the docker run command to instantiate one or more container instances from the image;

2. [Container technology] and virtual machine technology

Containers vs Virtual Machines

2.1 Same

Both are virtual technologies that provide a relatively independent operating environment for applications. They all get rid of direct dependence on physical resources, and use computing resources efficiently in a shared manner with each other.

2.2 Different

[Virtual machines] usually need to rely on Hypervisor technology, which can allocate an independent physical environment and operating system to virtual machines, while containers are based on Docker Engine and directly use the operating system of the host machine to allocate virtual resources, eliminating the need for each virtual machine. The unit installs the Guest OS, which greatly reduces the construction cost and operation cost of the image.

Therefore, under the same physical resources, containers can run more virtual units than virtual machines, and are more lightweight and efficient.

3. How to install Docker

3.1 Uninstall the old version

Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them and their associated dependencies.

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \

If yum reports that these packages are not installed, that’s fine too.

3.2 Install Docker

Officially recommended repository installation method:
Note: Other installation methods – official installation manual

Before installing Docker Engine for the first time on a new host, you need to set up a Docker repository. After that, you can install and update Docker from the repository.

Install the yum-utils package (provides the yum-config-manager utility)

yum install -y yum-utils

Set the Alibaba Cloud docker image address as the repository (the official document image address is the external network, which is relatively slow)

yum-config-manager \
    --add-repo \

Update the Yum package index

yum makecache fast

Install the DOCKER engine

yum install docker-ce docker-ce-cli containerd.io

start docker

systemctl start docker

After startup, you can view the docker information and version, and enter the version command to check whether there is relevant version information

docker version

docker info

3.3 Configuring Alibaba Cloud Image Acceleration

Official website: https://cr.console.aliyun.com/cn-beijing/instances/mirrorsRelated

vim /etc/docker/daemon.json
 ## Fill in the Alibaba Cloud image
  "registry-mirrors": ["https://25o6jk0m.mirror.aliyuncs.com"]

restart docker

sudo systemctl daemon-reload
sudo systemctl restart docker

You may also like...

Leave a Reply

Your email address will not be published.