直接替换/etc/docker/daemon.json文件内容
{
"registry-mirrors": [
"https://docker.1ms.run",
"https://dockerproxy.net",
"https://docker.m.daocloud.io",
"https://docker.1panel.live"
],
"insecure-registries": [],
"debug": false,
"experimental": false,
"features": {
"buildkit": true
}
}linuxmirrors
在中国大陆访问Docker Hub官方镜像往往面临访问速度较慢的问题,因此建议通过国内镜像加速器提升访问效率。
推荐一款实用性较强的一键配置工具:该工具提供的官方网站集成了Linux与Docker环境的镜像一键配置功能,用户仅需执行一行命令即可完成配置,全程零技术门槛,且无需额外安装依赖组件。
Docker 安装与换源脚本,优先使用这个
bash <(curl -sSL https://linuxmirrors.cn/docker.sh)具体使用方法,跳转查看
以下是常用可用的 Docker 镜像源和加速器:
1. 阿里云 Docker 镜像加速器
官方文档:阿里云容器镜像服务
配置方法:
登录阿里云容器镜像服务。
获取个人专属加速器地址,例如:
https://<your-id>.mirror.aliyuncs.com配置 Docker:
# Linux / Mac sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://<your-id>.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
2. 腾讯云 Docker 镜像加速器
官方文档:腾讯云镜像加速
配置示例:
sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://mirror.ccs.tencentyun.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
3. 华为云 Docker 镜像加速器
官方文档:华为云镜像加速
配置示例:
sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://docker.mirrors.huaweicloud.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
4. 网易云 Docker 镜像加速器
镜像地址:
https://hub-mirror.c.163.com配置方式同上,将
"registry-mirrors"设置为该地址即可。
5. 总结
推荐优先使用 阿里云、腾讯云 的加速器,因为稳定性和访问速度最佳。配置完成后,可以用以下命令测试:
docker info | grep Mirrors
如果返回加速器地址,说明配置成功。