Instale o Docker no CentOS 7.9
Diretório de artigos
1. Blogs relacionados
【Docker】002-Instalação do Docker
https://blog.csdn.net/qq_29689343/article/details/115261766
Esta nota não está escrita em Markdown, é inconveniente modificá-la, então abra um novo registro!
2. Instale o Docker
1. Instalação device-mapper-persistent-data
e lvm2
duas dependências
device-mapper-persistent-data
ÉLinux
um driver de armazenamento na parte inferior eLinux
tecnologia de armazenamento avançada na parte superior.Lvm
A função é criar partições de disco lógico.
yum install -y yum-utils device-mapper-persistent-data lvm2
# 更新yum软件包索引
yum makecache fast
Docker
2. Adicionar fonte de espelho Alibaba Cloud
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3. Instale o Docker Community Edition
yum install docker-ce -y
4. Comece
systemctl start docker
systemctl enable docker
# 查看版本
docker -v
# Docker version 24.0.2, build cb74dfc
5. Execute o teste
Primeiro configure o 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 o acelerador Alibaba Cloud Mirror
https://cr.console.aliyun.com/cn-hangzhou/instances
Após Docker
a conclusão da instalação, quando vamos extrair docker
a imagem espelhada, geralmente vamos à docker
fonte oficial para extrair a imagem espelhada por padrão. Porém, a velocidade da rede doméstica é muito lenta, por isso optamos por substituí-la pela 阿里云镜像仓库
fonte para acelerar o download do espelho.
Faça login no site oficial do Alibaba Cloud e abra o serviço de espelhamento de contêiner do Alibaba Cloud . Clique na parte inferior do menu esquerdo 镜像加速器
e selecione CentOS
(conforme mostrado abaixo). Execute o comando de acordo com as instruções do site oficial para alterar docker
o endereço de origem da imagem.
# 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