配置加速镜像

配置加速镜像

镜像站

  • Docker中国区官方镜像
    • https://registry.docker-cn.com
  • 网易
    • http://hub-mirror.c.163.com
  • 中国科技大学
    • https://docker.mirrors.ustc.edu.cn
  • 阿里云容器(先点击下方的连接进去获取自己的容器地址)
    • https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

使用

# 创建文件夹
sudo mkdir -p /etc/docker
# 将内容写入到daemon.json里
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["http://hub-mirror.c.163.com"]
}
EOF
# 重新加载daemon
sudo systemctl daemon-reload
# 重启docker
sudo systemctl restart docker

检查是否设置成功

  • “Registry Mirrors”,这一行的连接和我们设置的一样说明修改成功。
[root@localhost ~]# docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 2
 Server Version: 20.10.2
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
 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.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-1062.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 972.4MiB
 Name: localhost.localdomain
 ID: ZZXL:RI62:JWEF:V5YR:D63G:WO66:6NTO:SHOC:RCPV:FS7H:MM6V:UNUM
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  http://hub-mirror.c.163.com/
 Live Restore Enabled: false

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled