容器镜像加速器使用说明

Docker 配置教程:

为了加速镜像拉取,你可以使用以下命令设置 registry mirror:


sudo tee /etc/docker/daemon.json <<EOF
{
    "registry-mirrors": ["https://hub.registry-mirrors.top"]
}
EOF

重启Docker使配置生效:


sudo systemctl daemon-reload
sudo systemctl restart docker

验证 Docker 配置

拉取镜像命令

docker pull library/alpine:latest

或者

docker pull hub.registry-mirrors.top/library/alpine:latest

Podman 配置教程

Podman 是一个无守护进程的容器引擎,用于在 Linux 系统上开发、管理和运行 OCI 容器。与 Docker 类似,Podman 也支持配置镜像源来加速容器镜像的拉取。

以下是 Podman 的镜像源配置方法:

方法一:全局配置(推荐) 创建或编辑 Podman 的全局配置文件:

sudo mkdir -p /etc/containers
sudo tee /etc/containers/registries.conf <<EOF
unqualified-search-registries = ["docker.io"]

[[registry]]
prefix = "docker.io"
location = "docker.io"

[[registry.mirror]]
location = "hub.registry-mirrors.top"

EOF

方法二:用户级配置 为当前用户创建配置文件:

mkdir -p ~/.config/containers
tee ~/.config/containers/registries.conf <<EOF
unqualified-search-registries = ["docker.io"]

[[registry]]
prefix = "docker.io"
location = "docker.io"

[[registry.mirror]]
location = "hub.registry-mirrors.top"

EOF

验证 Podman 配置

测试拉取一个小镜像验证配置是否生效:

1. 测试拉取镜像
podman pull hello-world

1. 查看镜像是否成功拉取
podman images hello-world

如果配置正确,应该能够快速拉取镜像并看到相应的输出。

Podman 特殊说明:

  • Podman 配置文件支持多个镜像源,会按顺序尝试
  • 用户级配置优先于全局配置
  • 可以为不同的仓库配置不同的镜像源
  • Podman 4.0+ 版本支持更灵活的镜像源配置

更多镜像


源站:docker.io => 镜像: hub.registry-mirrors.top # docker hub 镜像仓库
源站:gcr.io => 镜像: gcr.registry-mirrors.top # Google Container Registry
源站:ghcr.io => 镜像: ghcr.registry-mirrors.top # GitHub Container Registry
源站:quay.io => 镜像: quay.registry-mirrors.top # Quay 镜像仓库
源站:registry.k8s.io => 镜像: k8s.registry-mirrors.top # Kubernetes 镜像仓库
源站:k8s.gcr.io => 镜像: k8sgcr.registry-mirrors.top # Google Kubernetes 镜像仓库
源站:nvcr.io => 镜像: 源站:nvcr.registry-mirrors.top # NVIDIA GPU 镜像仓库
源站:docker.elastic.co => 镜像: elastic.registry-mirrors.top # Elastic 镜像仓库
源站:mcr.microsoft.com => 镜像: mcr.registry-mirrors.top # Microsoft Container Registry