全栈直通车-王世彪的博客
关注公众号
  • 开发桌面程序
  • javascript教程
  • css样式
  • vuejs
  • 部署免费CDN
  • SEO搜索引擎优化
  • vuepress教程
  • redis分布式缓存
  • Golang
  • PHP
  • Python
  • Java
  • NodeJs
  • tomcat
  • ELK
  • Mysql数据库
  • Nosql数据库
  • C/C++底层开发
  • 音视频/流媒体
  • linux服务器
  • nginx服务器
  • 容器技术
  • 负载均衡
  • 项目管理
  • 持续集成
  • 大数据
  • 微信公众号运营
  • markdown用法
赞一个
友链
联系作者

王世彪

努力做个影响他人滴人
关注公众号
  • 开发桌面程序
  • javascript教程
  • css样式
  • vuejs
  • 部署免费CDN
  • SEO搜索引擎优化
  • vuepress教程
  • redis分布式缓存
  • Golang
  • PHP
  • Python
  • Java
  • NodeJs
  • tomcat
  • ELK
  • Mysql数据库
  • Nosql数据库
  • C/C++底层开发
  • 音视频/流媒体
  • linux服务器
  • nginx服务器
  • 容器技术
  • 负载均衡
  • 项目管理
  • 持续集成
  • 大数据
  • 微信公众号运营
  • markdown用法
赞一个
友链
联系作者
  • linux

  • macOS

  • nginx

  • docker

    • centos6安装docker服务
    • centos7安装docker服务
    • ubuntu安装docker服务
    • docker修改镜像存储路径
    • 加速docker镜像下载速度
      • 1. 准备镜像地址
      • 2. 配置镜像地址
      • 3. 重启 docker 服务
      • 4. 验证
      • 5. 下载 docker 镜像
    • linux安装docker-compose
    • docker-compose常用命令
    • docker基础命令
    • 创建sonarqube docker服务
    • linux安装docker私有仓库
    • docker编排工具rancher
    • 安装pdf转换服务gotenberg
    • docker参考文档
  • 负载均衡

  • 项目管理

  • 持续集成

  • 大数据

  • 域名

  • 运维
  • docker
王世彪
2020-11-18

加速docker镜像下载速度

# 加速 docker 镜像下载速度

本文讲解如何加速 docker 镜像的下载速度。默认情况下 docker 镜像是从官网下载,有些慢,那么我们可以通过配置国内的镜像地址,来加速镜像的下载速度。常用的国内镜像地址有阿里云、网易、七牛云。

注意: 要求 Docker 客户端版本 > 1.10.0

# 1. 准备镜像地址

  • 网易
    http://hub-mirror.c.163.com
  • 阿里云
    https://<你的 ID>.mirror.aliyuncs.com
    登录阿里云平台,访问地址https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors即可看到专属加速地址。
  • 七牛云
    https://reg-mirror.qiniu.com
  • docker中国 https://registry.docker-cn.com
  • 中科大 http://docker.mirrors.ustc.edu.cn

# 2. 配置镜像地址

编辑配置文件/etc/docker/daemon.json, 配置镜像地址:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://iuq5x200.mirror.aliyuncs.com", "https://registry.docker-cn.com", "http://docker.mirrors.ustc.edu.cn", "http://hub-mirror.c.163.com"]
}
EOF

镜像地址可以配置多个。

# 3. 重启 docker 服务

需要重启 docker 服务,镜像地址的配置才会生效。执行如下命令重启 docker 服务:

[root@VM-0-6-centos dockerfile]# systemctl daemon-reload                              
[root@VM-0-6-centos dockerfile]# systemctl restart docker
[root@VM-0-6-centos dockerfile]#

# 4. 验证

执行 docker info 可以查看加速镜像地址是否已生效。
验证过程如下:

[root@VM-0-6-centos mysql]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 30
 Server Version: 19.03.13
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.18.0-193.6.3.el8_2.x86_64
 Operating System: CentOS Linux 8 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.69GiB
 Name: VM-0-6-centos
 ID: QNXQ:J3EK:5AWG:JNJK:UU4G:AVKL:LYD4:N5JO:NUUD:6AZV:YO7H:GMLY
 Docker Root Dir: /data/docker/storage
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

[root@VM-0-6-centos mysql]# systemctl restart docker
[root@VM-0-6-centos mysql]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 30
 Server Version: 19.03.13
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.18.0-193.6.3.el8_2.x86_64
 Operating System: CentOS Linux 8 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.69GiB
 Name: VM-0-6-centos
 ID: QNXQ:J3EK:5AWG:JNJK:UU4G:AVKL:LYD4:N5JO:NUUD:6AZV:YO7H:GMLY
 Docker Root Dir: /data/docker/storage
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://reg-mirror.qiniu.com/
 Live Restore Enabled: false

[root@VM-0-6-centos mysql]#

可以看出, docker 镜像加速地址已经配置完毕。

# 5. 下载 docker 镜像

可以使用docker pull下载 docker 镜像了。

#运维#docker#linux
上次更新: 2021-01-18 20:27:25
docker修改镜像存储路径
linux安装docker-compose

← docker修改镜像存储路径 linux安装docker-compose→

最近更新
01
mysql创建用户
04-09
02
golang错误处理最佳实践
03-17
03
基于proto文件生成rpc接口定义文档
03-11
更多文章>
Theme by Vdoing | Copyright © 2019-2022 王世彪 | MIT License
冀ICP备19016776号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式