“This is the 26th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

1. Docker architecture

Docker has three basic concepts

  • Image: A Docker Image is a template used to create Docker containers. Multiple containers can be created from this Image.
  • Container: The relationship between an Image and a Container is similar to that between a class and an object in object-oriented programming. An Image is a static definition and a Container is an entity of the Image runtime. Containers can be created, started, stopped, deleted, paused, and so on. A container is a single application or group of applications that run independently.
  • Repository: A Repository can be thought of as a code control center that holds images. A Docker Registry can contain multiple repositories, and each Repository can contain multiple tags, and each Tag corresponds to an image. Typically, a repository contains images of different versions of the same software, and labels are often used to match versions of the software. We can specify which version of this software is the mirror by using the format < repository >:< tag >. If no label is given, latest is used as the default label.

Docker architecture diagram:

Docker architecture diagram noun introduction:

Docker uses a client-server (C/S) architecture pattern that uses remote apis to manage and create Docker containers.

Docker Client: The Docker Client communicates with the Docker daemon process by using the Docker SDK through command lines or other tools.

Docker Host: A physical or virtual machine that executes Docker daemons and containers.

Docker Hub

Docker Hub: Docker Hub provides a huge set of images for use.

Docker Hub address: hub.docker.com

2, centOS install Docker

Operating System Requirements

1. Maintenance versions of CentOS 7 or 8 are required. Archived versions are not supported or tested.

You must enable the CentOS Extras repository. By default, this repository is enabled, but if it is disabled, you need to re-enable it.

Overlay2 is recommended to store drivers.

Uninstall the previous version

If there is an old version of the Docker installed before (Docker name is Docker or docker-engine), you need to delete it first.

yum remove docker \
           docker-client \
           docker-client-latest \
           docker-common \
           docker-latest \
           docker-latest-logrotate \
           docker-logrotate \
           docker-engine
Copy the code

It doesn’t matter if yum reports that these packages are not installed.

The above operation will only delete the docker itself, but the contents saved in /var/lib/docker/ of the old version, including images, containers, volumes, and networks, need to be manually deleted.

Install: Install using a repository (recommended)

1. Install the yum utils package

yum install -y yum-utils
Copy the code

2. Configure the mirror vault

Yum - config - manager \ - add - repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # use ali domestic source installation docker, fastCopy the code

3. Update yum package index

yum makecache fast
Copy the code

4. Install Docker CE

4.1. Install the latest Docker CE version:

yum install docker-ce docker-ce-cli containerd.io
Copy the code

If this is the first time you have installed a package from a recently added repository, you will be prompted to accept the GPG key and a fingerprint of the key will be displayed. Verify that the fingerprint is correct, and if so, accept the key. The prints should match.

060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
Copy the code

4.2. Install a specific version of Docker CE

On production systems, you should install a specific version of Docker CE instead of always using the latest version.

Query the available version: yum list docker – ce – showduplicates | sort – r

[root@CHENG /]# yum list docker-ce --showduplicates | sort -r Loading mirror speeds from cached hostfile Loaded plugins: Fastestmirror Installed Packages Docker-ce.x86_64 3:20.10.9-3.EL7 Docker-CE-Stable Docker-CE.x86_64 3:20.10.8-3.EL7 X86_64 3:20.10.7-3.el7 docker-ce-stable docker-ce. X86_64 3:20.10.6-3.el7 docker-ce-stable X86_64 3:20.10.5-3.el7 docker-ce-stable docker-ce. X86_64 3:20.10.4-3.el7 docker-ce-stable docker-ce. X86_64 3:20.10.4-3.el7 docker-ce-stable docker-ce X86_64 3:20.10.2-3.el7 docker-ce-stable docker-ce. X86_64 3:20.10.1-3.el7 Docker-ce-stable docker-ce. X86_64 3:20.10.1-3.el7 X86_64 3:20.10.11-3.el7 docker-ce-stable docker-ce. X86_64 3:20.10.11-3. el7@docker-ce-stable X86_64 3:20.10.10-3.el7 docker-ce-stable docker-ce. X86_64 3:20.10.10-3.el7 docker-ce-stable docker-ce. X86_64 3:20.10.10-3.el7 docker-ce-stable docker-ce X86_64 3:19.03.8-3.el7 docker-ce-stable docker-ce. X86_64 3:19.03.7-3.el7 Docker-ce-stable docker-ce X86_64 3:19.03.6-3.el7 docker-ce-stable docker-ce. X86_64 3:19.03.5-3.el7 docker-ce-stable X86_64 3:19.03.3-3.el7 docker-ce-stable docker-ce. X86_64 3:19.03.3-3.el7 docker-ce-stable docker-ce. X86_64 3:19.03.3-3.el7 docker-ce-stable docker-ce X86_64 3:19.03.15-3.el7 docker-ce-stable docker-ce. X86_64 3:19.03.14-3.el7 Docker-ce-stable docker-ce X86_64 3:19.03.1-3.el7 docker-ce-stable docker-ce. X86_64 3:19.03.13-3.el7 docker-ce-stable X86_64 3:19.03.11-3.el7 docker-ce-stable docker-ce. X86_64 3:19.03.11-3.el7 docker-ce-stable docker-ce X86_64 3:19.03.0-3.el7 docker-ce-stable docker-ce. X86_64 3:18.09.9-3.el7 docker-ce-stable docker-ce X86_64 3:18.09.8-3.el7 docker-ce-stable docker-ce. X86_64 3:18.09.7-3.el7 docker-ce-stable X86_64 3:18.09.5-3.el7 docker-ce-stable docker-ce. X86_64 3:18.09.5-3.el7 docker-ce-stable docker-ce. X86_64 3:18.09.5-3.el7 docker-ce-stable docker-ce X86_64 3:18.09.3-3.el7 docker-ce-stable docker-ce. X86_64 3:18.09.2-3.el7 docker-ce-stable docker-ce X86_64 3:18.09.1-3.el7 docker-ce-stable docker-ce. X86_64 3:18.09.0-3.el7 docker-ce-stable El7 docker-ce-stable docker-ce. X86_64 18.06.2.ce-3.el7 docker-ce-stable docker-ce. X86_64 18.06.2.ce-3.el7 docker-ce-stable docker-ce El7 docker-ce-stable docker-ce. X86_64 18.06.0.ce-3.el7 docker-ce-stable docker-ce. X86_64 18.06.0.ce-3.el7 docker-ce-stable docker-ce Centos docker-ce-stable docker-ce. X86_64 18.03.0.ce-1.el7. Centos docker-ce-stable docker-ce Ce -1.el7. Centos docker-ce-stable docker-ce. X86_64 17.12.0. Ce -1.el7 Ce -1.el7. Centos docker-ce-stable docker-ce. X86_64 17.09.0.ce-1.el7 Ce -1. El7. Centos docker-ce-stable docker-ce. X86_64 17.06.1. Ce -1 Centos docker-ce-stable docker-ce. X86_64 17.03.3.ce-1.el7 docker-ce-stable docker-ce Ce -1. El7. Centos docker-ce-stable docker-ce. X86_64 17.03.1. Ce -1 Centos docker-ce-stable * centos-SCLo-SCLo: mirrors.163.com * centos-sclo-RH: mirrors.163.com Available PackagesCopy the code

Install the specified version:

Yum install docker - ce - 18.03.1. Ce - 1. El7. Centos - yCopy the code

5. Start Docker

systemctl start docker
Copy the code

6. Check the Docker version

docker version
Copy the code

Verify that the Docker Engine is installed correctly by running the Hello-world image

docker run hello-world
Copy the code

This command downloads the test image and runs it in the container. When the container runs, it prints a message similar to the one sent, indicating that the installation was successful.

8. View the hello-world image downloaded above

docker images
Copy the code

3. Uninstall the Docker engine

Uninstalling the Docker Engine, CLI, and Containerd packages

yum remove docker-ce docker-ce-cli containerd.io
Copy the code

2. Images, containers, volumes, or custom configuration files on the host are not automatically deleted. Delete all mirrors, containers, and volumes:

Rm -rf /var/lib/docker # rm -rf /var/lib/containerdCopy the code

4. Configure Ali Cloud image acceleration

1. Log in to Aliyun and find the container mirroring service

2. Find the mirror acceleration address

3. Configuration and use

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://lidtl20v.mirror.aliyuncs.com"]
}
EOF

sudo systemctl daemon-reload

sudo systemctl restart docker
Copy the code

Ali cloud image accelerated configuration completed.