Docker镜像换源

文章目录

  • Docker镜像换源
    • [1 更新Docker镜像源](#1 更新Docker镜像源)
    • [2 重启Docker服务](#2 重启Docker服务)
    • [3 验证换源是否成功](#3 验证换源是否成功)

Docker镜像换源

环境: Ubuntu22.04

由于各种网络政策,在国内访问DockerHub速度会非常缓慢,大家一般都会采取更换镜像源的方式来进行加速。

1 更新Docker镜像源

直接将下列文本粘贴到终端中,然后回车运行即可。

sh 复制代码
pzs@pzs-jammy:~$ sudo tee /etc/docker/daemon.json << 'EOF'
{
    "registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://docker.imgdb.de",
    "https://docker-0.unsee.tech",
    "https://docker.hlmirror.com",
    "https://cjie.eu.org"
    ]
}
EOF

注:上面的镜像不一定能够一直使用,如果不能使用,请自行找其他镜像源!!!

2 重启Docker服务

sh 复制代码
pzs@pzs-jammy:~$ sudo systemctl daemon-reload 
pzs@pzs-jammy:~$  sudo systemctl restart docker

3 验证换源是否成功

sh 复制代码
pzs@pzs-jammy:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d5e71e642bf5: Download complete 
4f55086f7dd0: Pull complete 
Digest: sha256:5e23090353324d887c48ad5e5c56d294eab81588df9605b07d1afe895f9cc8f8
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/
相关推荐
牢姐与蒯2 小时前
Linux信号(二).信号产生续 && 信号保存
linux·运维·服务器·ubuntu
何中应2 小时前
Jenkins 如何给设置公司 Logo
运维·ci/cd·jenkins
Szime2 小时前
项目结束后,剩余的电子元器件怎么处理?——从“库存滞留”到“资产盘活”的更高解法
运维·嵌入式硬件
中杯可乐多加冰2 小时前
解决方案:CEB 文件 Web 端在线预览方案,Linux部署ceb文件在线预览工具
linux·运维·前端·ceb
troy1282 小时前
从 JIRA 到监控:一条完整的 DevOps 交付流水线实战
运维·devops·jira
Stark-C2 小时前
IDM的免费替代,老牌下载器时隔三年再次更新,NAS部署Motrix
docker
何中应2 小时前
Jenkins 如何配置工作节点
运维·ci/cd·jenkins
谢亮_vipxieliang2 小时前
容器日志收集与管理:从 stdout 规范到 ELK/Loki 落地
运维·网络·人工智能·elk·docker·容器
YOLO数据集集合2 小时前
风力发电机检测数据集 | 风机检测 电缆塔识别 风电运维 无人机巡检 9122期
运维·人工智能·目标检测·目标跟踪·无人机·风力发电·电力巡检