Instale Docker en CentOS 7.9
Directorio de artículos
1. Blogs relacionados
【Docker】 002-Instalación de Docker
https://blog.csdn.net/qq_29689343/article/details/115261766
Esta nota no está escrita en Markdown, es inconveniente modificarla, ¡así que abra un nuevo registro!
2. Instale Docker
1. Instalar device-mapper-persistent-data
y lvm2
dos dependencias.
device-mapper-persistent-data
EsLinux
un controlador de almacenamiento en la parte inferior yLinux
tecnología de almacenamiento avanzada en la parte superior.Lvm
La función es crear particiones de disco lógicas.
yum install -y yum-utils device-mapper-persistent-data lvm2
# 更新yum软件包索引
yum makecache fast
Docker
2. Agregue la fuente espejo de Alibaba Cloud
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3. Instale Docker Community Edition
yum install docker-ce -y
4. Empezar
systemctl start docker
systemctl enable docker
# 查看版本
docker -v
# Docker version 24.0.2, build cb74dfc
5. Ejecute la prueba
Primero configure Alibaba Cloud Mirror Accelerator
docker run hello-world
# 显示“……Hello from Docker!……”代表运行成功!
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
3. Configurar el acelerador Alibaba Cloud Mirror
https://cr.console.aliyun.com/cn-hangzhou/instances
Una vez Docker
completada la instalación, cuando vayamos a extraer docker
la imagen, normalmente iremos a docker
la fuente oficial para extraer la imagen de forma predeterminada. Sin embargo, la velocidad de la red nacional es demasiado lenta, por lo que optamos por reemplazarla con 阿里云镜像仓库
la fuente para acelerar la descarga espejo.
Inicie sesión en el sitio web oficial de Alibaba Cloud y abra el servicio de duplicación de contenedores de Alibaba Cloud . Haga clic en la parte inferior del menú de la izquierda 镜像加速器
y seleccione CentOS
(como se muestra a continuación). Ejecute el comando de acuerdo con las indicaciones del sitio web oficial para cambiar docker
la dirección de origen de la imagen.
# CentOS
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://wgsbq2gq.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker