Docker study notes: Is docker installation slow? Configure domestic docker image source

docker installation and deployment

Preparation

Brand new virtual machine, with the highest configuration possible: 4G memory/CPU 4-core disk 100G

Official website documentation: Install Docker Engine on CentOS | Docker Documentation

step

1. Uninstall the old version of docker

[root@docker ~]# yum remove docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-engine

2.rpm source installation

[root@docker ~]# yum install -y yum-utils #下载提供yum-config-manager的安装包
[root@docker ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo #下载docker仓库到/etc/yum.repos.d/下

The download speed of foreign docker image sources is too slow, so I used Alibaba’s docker image source.

[root@docker ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Insert image description here

3. Download docker engine

[root@docker ~]# yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

The role of each engine

docker-ce docker server side
docker-ce-cli docker client
containerd.io The daemon process containerd, the bottom layer is used to manage docker
docker-buildx-plugin Extended docker command to support functions provided by Moby BuildKit
docker-compose-plugin Let the remote Docker run the container according to the specified docker-compose.yml arrangement

4. Check docker version

[root@docker ~]# docker version

Insert image description here

5. Start docker and set it to start automatically at boot

[root@docker ~]# systemctl start docker
[root@docker ~]# systemctl enable docker

6. Check whether docker is installed successfully

[root@docker docker]# docker run hello-world

Insert image description here

The failure shown here is because I am using Alibaba Cloud's docker image source. Due to domestic network reasons, an accelerator needs to be configured to accelerate

Obtain the Alibaba Cloud mirror acceleration address: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

Configure Alibaba Cloud Image Accelerator

1. Create a new folder
[root@docker docker]# mkdir -p /etc/docker/
2. Modify the daemon configuration file /etc/docker/daemon.json to use the accelerator
[root@docker docker]# vi /etc/docker/daemon.json

{
  "registry-mirrors": ["https://52152375.mirror.aliyuncs.com"]
}

Note: https://52152375.mirror.aliyuncs.com is my own Alibaba Cloud mirror accelerator. You need to log in to Alibaba Cloud to copy your own!

3. Restart docker
[root@docker docker]# systemctl daemon-reload
[root@docker docker]# systemctl restart docker

Recheck whether docker is installed successfully

[root@docker docker]# docker run hello-world

Insert image description here

At this point, docker is successfully installed and running!

Guess you like

Origin blog.csdn.net/qq_57629230/article/details/130660671