Skip to main content

智能Docker镜像拉取工具 - 自动选择最优镜像源

Project description

DockerPull 智能镜像拉取工具

🚀 介绍

DockerPull 是一个智能的 Docker 镜像拉取工具,能够自动检测并使用最优的镜像加速源,解决 Docker 镜像拉取慢或失败的问题。

✨ 主要特性

  • 智能镜像源选择: 自动检测 20+ 个可用镜像加速源,选择最优源进行拉取
  • 实时进度显示: 显示镜像拉取的实时进度(Downloading/Extracting/Pulling)
  • 调试模式: 支持 -d 参数输出实际执行的完整命令,便于调试
  • 耗时统计: 自动统计并显示整个拉取过程的总耗时
  • 容错机制: 支持重试机制,单个镜像源失败自动切换到下一个
  • 命令行友好: 使用 argparse 标准库,支持完整的命令行参数和帮助

📦 安装

系统要求

  • Python 3.6+
  • Docker 已安装

快速安装

# 使用pip3安装
pip3 install dps_liumou_Stable

🎯 使用方法

基本用法

# 拉取镜像(自动选择最优镜像源)
dps nginx:latest

# 拉取指定版本
dps python:3.9

# 列出所有可用镜像源
dps --list-mirrors

# 列出本地镜像
dps --local-images

高级用法

# 调试模式 - 显示实际执行的完整命令
dps nginx:latest -d

# 设置超时时间(秒)
dps nginx:latest --timeout 600

# 设置最大重试次数
dps nginx:latest --max-retries 5

# 强制使用镜像站(适用于非Docker Hub镜像)
dps gcr.io/google/cadvisor:latest --force-mirror

# 组合使用
dps nginx:latest -d --timeout 600 --max-retries 5

非Docker Hub镜像支持

对于非Docker Hub镜像(如 gcr.io/google/cadvisor:latest),工具会自动检测并默认不使用镜像站加速,直接拉取:

# 非Docker Hub镜像 - 默认不使用镜像站
dps gcr.io/google/cadvisor:latest

# 非Docker Hub镜像 - 强制使用镜像站
dps gcr.io/google/cadvisor:latest --force-mirror

命令行参数

positional arguments:
  image_name            要拉取的镜像名称,如 nginx:latest

options:
  -h, --help            显示帮助信息
  --list-mirrors        列出所有可用的镜像源
  --local-images        列出本地Docker镜像
  --timeout TIMEOUT     Docker命令超时时间(秒),默认300秒
  --max-retries MAX_RETRIES
                        每个镜像源的最大重试次数,默认3次
  -d, --debug           调试模式,输出实际执行的完整命令
  --force-mirror        强制使用镜像站(即使非Docker Hub镜像)

使用示例:
  dps nginx:latest                    # 拉取nginx镜像
  dps python:3.9                     # 拉取python镜像
  dps gcr.io/google/cadvisor:latest   # 拉取非Docker Hub镜像
  dps --list-mirrors                   # 列出可用镜像源
  dps --local-images                   # 列出本地镜像
  dps -h                              # 显示帮助信息

🎨 输出示例

正常拉取模式

🎯 开始智能拉取镜像: nginx:latest
==================================================
📋 找到 22 个可用镜像源
  1. 阿里云镜像仓库 - https://registry.cn-hangzhou.aliyuncs.com
  2. 网易云镜像仓库 - https://hub-mirror.c.163.com
  ...

🔄 尝试镜像源 1/22: 阿里云镜像仓库
🔗 URL: https://registry.cn-hangzhou.aliyuncs.com
📥 Downloading  6e7cb3f1d8a5:  45.67MB/123.45MB
📥 Extracting  6e7cb3f1d8a5:  100%
✅ 成功拉取镜像: nginx:latest
==================================================
🎉 镜像拉取成功: nginx:latest
📍 使用的镜像源: 阿里云镜像仓库
⏱️  总耗时: 15.3秒

调试模式

🎯 开始智能拉取镜像: nginx:latest
==================================================
🔍 执行命令: docker pull https://registry.cn-hangzhou.aliyuncs.com/nginx:latest
📥 Downloading  6e7cb3f1d8a5:  45.67MB/123.45MB
📋 latest: Pulling from library/nginx
📋 Digest: sha256:1234567890abcdef...
✅ 命令执行成功: docker pull https://registry.cn-hangzhou.aliyuncs.com/nginx:latest (耗时: 12.5秒) 成功拉取镜像: https://registry.cn-hangzhou.aliyuncs.com/nginx:latest
🏷️  设置镜像标签: https://registry.cn-hangzhou.aliyuncs.com/nginx:latest -> nginx:latest
✅ 成功设置镜像标签: nginx:latest
🗑️  删除镜像: https://registry.cn-hangzhou.aliyuncs.com/nginx:latest
==================================================
🎉 镜像拉取成功: nginx:latest
📍 使用的镜像源: 阿里云镜像仓库
⏱️  总耗时: 15.3秒

🔧 技术特性

  • 智能镜像源管理: 实时检测镜像源可用性,自动过滤失效源
  • 实时输出: 使用 subprocess.Popen 实现实时进度显示
  • 错误处理: 完善的异常处理和重试机制
  • 跨平台: 支持 Windows、Linux、macOS
  • 标准库: 使用 argparse 标准库,无需额外依赖

🤝 参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

📄 许可证

MIT License - 详见 LICENSE 文件


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dps_liumou_stable-1.0.2.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dps_liumou_stable-1.0.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file dps_liumou_stable-1.0.2.tar.gz.

File metadata

  • Download URL: dps_liumou_stable-1.0.2.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for dps_liumou_stable-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a37acbd0c9d0b37533e9ef5f9aca255da16e5fffbd05126c50f6fa689c233c58
MD5 0c355bb83e0399affb5580c4cb064ed6
BLAKE2b-256 4c81e136f9dfb9eb11ee5aced93775944a0a574d358a210fe11e5936965c7925

See more details on using hashes here.

File details

Details for the file dps_liumou_stable-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dps_liumou_stable-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7857a3fee3dcdd93781da58e07cb3de562c9d3da9238a52e2c750d7f89ee0945
MD5 c9e09b6a84ff6ae9302cb3c5d3dae971
BLAKE2b-256 7b4e8de7a114a30326c7a5e7ed1a883bd13e8c1720bf65e882fcbdbcbaa29ec9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page