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/
相关推荐
A-刘晨阳14 小时前
Kubernetes 查询证书有效期及续签证书(适用于二进制部署)
云原生·容器·kubernetes·证书·cfssl
tz52514 小时前
Superpowers 游戏开发实战应用场景大纲
linux·运维·服务器
倔强的石头_15 小时前
Linux 电脑也能被 UU 远程连进去了:Linux PC 端内测上手,主控和被控我都试了
运维
Decay__19 小时前
PostgreSQL WAL 归档与时间点恢复 —— WAL 连续归档、recovery_target 时点恢复与 pg_rewind
运维·数据库·sql·postgresql
`Levie21 小时前
Docker-安装部署、容器管理(一)
docker·容器·eureka
Decay__1 天前
PostgreSQL 索引与 SQL 优化 —— B-tree、GiST、GIN、BRIN、执行计划与索引设计实战
运维·数据库·sql·postgresql
JWIPC1 天前
MyClaw 3.0 自动化数据采集实战指南
linux·运维·笔记·科技·深度学习·物联网·自动化
Kainy1 天前
生产服务器从机械盘迁移NVMe固态:旧盘不动、退路先行的六步实操全记录
运维·服务器
Henry-SAP1 天前
SAP BOM项目类别详解——L/T/R/N各类目的业务含义解析
运维
天空属于哈夫克31 天前
企业微信二次开发:解锁更多自动化应用场景
运维·自动化·企业微信