1.问题描述
在linux系统中,使用docker拉取rabbitmq速度缓慢,拉取到一半就没反应了
2.解决办法
(1)原因:doucker使用过程中,默认是使用国外的服务器(远程仓库)下载镜像,所以下载时会出现下载连接超时导致下载失败,因此需要为其配置镜像加速器,所以我们要在docker上配置一个国内的镜像服务器。
(2)在配置阿里云镜像加速器之前,使用命令查看docker的详细信息,查看是否配置了镜像加速
docker info
Client: Docker Engine - Community
Version: 24.0.5
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.11.2
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.20.2
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 9
Running: 3
Paused: 0
Stopped: 6
Images: 13
Server Version: 24.0.5
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
runc version: v1.1.8-0-g82f18fe
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 6
Total Memory: 1.936GiB
Name: linux100
ID: 85a6ebdc-0969-4d07-8295-4122304d83e0
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
#在此处查看是否配置了docker镜像加速
Registry Mirrors:
https://u478twun.mirror.aliyuncs.com/
Live Restore Enabled: false
3.阿里云镜像使用步骤
(1)注册和登录阿里云官网
https://www.aliyun.com/
(2)搜索框搜索容器镜像服务ACR
(3)点击镜像工具—镜像加速器—查看对应的操作系统的加速器网址,按照官方提示设置即可
# 在etc目录下创建一个docker文件夹
sudo mkdir -p /etc/docker
# 在/etc/docker文件夹下创建一个daemon.json文件,然后写入如下内容
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://phtv51hj.mirror.aliyuncs.com"]
}
EOF
# 重新加载docker的守护进程
sudo systemctl daemon-reload
# 重启docker服务
sudo systemctl restart docker
4.配置完成之后再次尝试使用命令拉取镜像即可
docker pull 镜像名称[:tag] #tag可以理解为镜像的版本
5.查看本地镜像
docker images [options] #可以添加一些常见的参数选项