Docker 国内镜像源配置

第 1 步:编辑 Docker 配置文件

打开终端,使用文本编辑器(如 nano 或 vim)打开或创建 Docker 的守护进程配置文件:

bash 复制代码
sudo nano /etc/docker/daemon.json

或者

bash 复制代码
sudo vim /etc/docker/daemon.json
第 2 步:替换为可用的镜像源

docker 镜像配置:

json 复制代码
{
  "registry-mirrors": [
		"https://docker.1ms.run",
		"https://do.nark.eu.org", 
		"https://dc.j8.work", 
		"https://docker.m.daocloud.io", 
		"https://dockerproxy.com", 
		"https://docker.mirrors.ustc.edu.cn",
		"https://docker.nju.edu.cn"
  ]
}
第 3 步:重启 Docker 服务

保存文件并退出编辑器(在 nano 中按 Ctrl+O 保存,Enter 确认,Ctrl+X 退出),然后重新加载配置并重启 Docker:

bash 复制代码
sudo systemctl daemon-reload
sudo systemctl restart docker
第 4 步:验证并重新拉取

验证镜像源是否已成功加载:

bash 复制代码
docker info | grep -A 5 "Registry Mirrors"

如果输出中显示了新的镜像源地址,如:

bash 复制代码
root@ubuntu-26:~# docker info | grep -A 5 "Registry Mirrors"
 Registry Mirrors:
  https://docker.1ms.run/
  https://docker.mirrors.ustc.edu.cn/
  https://hub-mirror.c.163.com/
  https://mirror.baidubce.com/
 Live Restore Enabled: false

即可重新运行测试:

bash 复制代码
docker run hello-world

出现以下内容代表成功:

bash 复制代码
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d5e71e642bf5: Download complete
4f55086f7dd0: Pull complete
Digest: sha256:11a3eb1597e864c51b3f56733cb2e8a90bf0c284bfc05f9444d81c558bc848aa
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/
相关推荐
会飞的大可1 小时前
AI 新闻周报 | 2026年10月19日 — 10月24日
1024程序员节
猿粪已尽1 小时前
mac 中 iTerm2 使用 rz、sz 上传下载文件详解,附 scp 操作指南
linux·macos·scp·lrzsz
CRMEB系统商城1 小时前
服装连锁的导购分销与企微私域
java·大数据·开发语言·人工智能·小程序·php·1024程序员节
拓恒技术1 小时前
城市管理中的无人机AI识别算法:架构、场景与落地
人工智能·算法·视觉检测·无人机·1024程序员节
成信吴彦祖1 小时前
当前专业的无人机RID侦测主站供应商主要有哪些
python·1024程序员节
宁波阿成1 小时前
CentOS 7.5 升级 PHP 至 8.3.36 完整实操记录
linux·centos·php
玥轩_5211 小时前
鸿蒙远程控制软件推荐:鸿蒙手机平板远程控制电脑哪个好用?
1024程序员节
PythonFun1 小时前
三分钟学会查看电脑MAC地址
1024程序员节