The docker image acceleration is configured, but the speed of docker pulling the image is still very slow

First of all, there are several reasons that affect the acceleration of docker pulling images. After checking one by one, you will find the problem.

1. Add the Ali yum source of docker

tee /etc/yum.repos.d/docker.repo <<-'EOF'

[dockerrepo]

name=Docker Repository

baseurl=http://mirrors.aliyun.com/docker-engine/yum/repo/main/centos/7/

enabled=1

gpgcheck=1

gpgkey=https://yum.dockerproject.org/gpg

EOF

Then use docker search to search for the mirror and pull the mirror

docker search  zabbix

date && docker pull monitoringartist/zabbix-3.0-xxl && date

2. At this time, the pull can be seen to be very slow, so you need to configure docker to accelerate

vi /etc/docker/daemon.json  #编辑此文件,添加以下文件


{

"registry-mirrors": [
     "https://docker.mirrors.ustc.edu.cn",
     "https://registry.docker-cn.com",
     "http://hub-mirror.c.163.com",
     "https://mirror.ccs.tencentyun.com"
]

}

Commonly used images are as follows: You can choose by yourself

HKUST: https://docker.mirrors.ustc.edu.cn/
NetEase: https://hub-mirror.c.163.com/
Qiniu Cloud Accelerator: https://reg-mirror.qiniu.com
Alibaba Cloud : https://<your ID>.mirror.aliyuncs.com
Tencent Cloud: https://mirror.ccs.tencentyun.com

Then restart the docker service

sudo systemctl daemon-reload
sudo systemctl restart docker

3. The third reason may be that the disk space in the root directory is not enough

Sometimes it prompts: no space left on device disk space is insufficient

When the disk is full, it is divided into inode and block.

The inode is generated when the file system is formatted and created. It is used to store the attribute information of the file and the location of the block. There is no file name. Creating a non-empty file occupies 1 inode and at least 1 block

The block is the location where the data is actually stored. The block size is divided into 1k 4k 8k. The default is 4K if the partition is larger than 500m. The file is very large and occupies multiple blocks. The file is very small. The remaining space of the 1k block cannot be used any longer, so the block consumption in the system is faster

df -h  #查看所有block使用情况,这里可以看到那个目录下的空间使用情况,需要留意/根目录的使用情况,如果很满的话将会影响后续软件安装和docker的镜像拉取等

du -sh /usr/* |grep G  #在根目录下执行该命令,查找大文件,再看根目录下的那个目录占用空间比较大,然后再进入到这些目录下再次执行该查找大文件的命令,直至找到那个占用空间大的文件或目录,确认该目录或文件非必要可以进行删除

df -h   #再次返回到根目录下执行该命令,就可以看到/根目录下的空间有所释放

You can also properly delete some files or directories under the home directory, and then allocate some space in the home directory to the root directory. I will talk about this operation later, and some clearing/operations under the root directory can also be effectively released. / root memory

Also, the inode is full (use df -h to find that there is still space)

df -i     #查看inode使用情况,然后根据返回,找到那个占用很大的空间的那个挂载点的目录下,即对应的后面的那个目录,查看该目录下的文件,文件小且多,评估以下这些文件是否必要,非必要可以进行删除

rm -rf 文件名   #删除文件


df -i    #再次查看inode使用情况,应该就不会那么满了

如果不知道小文件都怎么找,可以使用以下方法,找系统中 目录大小大于1M(目录一般大小为4K,所以目录要是大了那么文件必然很多)

find / -size +4k -type d |xargs ls -ldhi

Another situation is that the file has been occupied and has not been completely deleted, that is, there is space in df -h, but nothing can be put in it

lsof |grep deleted  #显示系统中被打开的文件,过滤出deleted字段

显示中第一列为:软件/服务名称
显示中第八列:文件大小
显示中第十列:文件的名字或路径
显示中第是一列:标记(硬链接数为0 进程调用数不为零 就会出现delete)



/etc/init.d/rsyslog restart   #重启对应的服务 释放磁盘空间 

df -h   #再次查看所有block使用情况

Guess you like

Origin blog.csdn.net/weixin_45190065/article/details/128216499