Instale Docker en CentOS 7.9

Instale Docker en CentOS 7.9

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-datay lvm2dos dependencias.

device-mapper-persistent-dataEs Linuxun controlador de almacenamiento en la parte inferior y Linuxtecnología de almacenamiento avanzada en la parte superior. LvmLa función es crear particiones de disco lógicas.

yum install -y yum-utils device-mapper-persistent-data lvm2

# 更新yum软件包索引
yum makecache fast

Docker2. 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 Dockercompletada la instalación, cuando vayamos a extraer dockerla imagen, normalmente iremos a dockerla 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 dockerla dirección de origen de la imagen.

imagen-20230622210412019

# 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

Supongo que te gusta

Origin blog.csdn.net/qq_29689343/article/details/131344361
Recomendado
Clasificación