-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
339 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,88 @@ | ||
# Docker Pull Tool | ||
# Docker Image Puller | ||
|
||
这是一个基于 `docker-drag` 实现的 Python 工具,用于从 Docker Hub 或其他镜像源下载 Docker 镜像并保存为 `.tar` 文件。支持以下功能: | ||
## 项目简介 | ||
|
||
- **新版 Docker Hub API 支持**:兼容 Docker Hub 的最新 API。 | ||
- **多架构支持**:可以指定下载的镜像架构(如 `amd64`、`arm64` 等)。 | ||
- **镜像源加速**:支持指定镜像源以加速下载。 | ||
- **简单易用**:通过命令行参数快速下载镜像。 | ||
Docker Image Puller 是一个强大的工具,用于从 Docker 仓库拉取镜像,支持国内镜像源加速和多架构支持。该工具采用 MIT 许可证,开放源代码,方便用户根据需要进行定制和扩展。 | ||
|
||
## 特点 | ||
|
||
--- | ||
- **国内镜像源加速**: 通过配置国内镜像源,大幅提高镜像下载速度。 | ||
- **多架构支持**: 支持多种架构(如 amd64, arm64),满足不同环境需求。 | ||
- **兼容最新 Docker Hub API**: 确保与 Docker Hub 的最新接口兼容,获取最新的镜像信息。 | ||
- **单文件 Python 脚本**: 便于携带和使用,无需复杂安装。 | ||
- **无依赖 EXE 执行**: 编译为独立 EXE 文件,无需安装 Python 环境,在 Releases 下载。 | ||
- **用户友好**: 提供交互式输入,简化操作流程。 | ||
- **优化性能**: 提高下载速度和可靠性。 | ||
|
||
## 使用方法 | ||
## 安装 | ||
|
||
### 通过 Git 克隆 | ||
|
||
### 基本命令 | ||
```bash | ||
python docker_pull.py <image_name> [options] | ||
git clone https://github.com/topcss/docker-pull-tar.git | ||
``` | ||
|
||
### 示例 | ||
下载 `alpine` 镜像的 `arm64` 架构版本,使用自定义镜像源加速下载: | ||
```bash | ||
python docker_pull.py alpine arm64 docker.xuanyuan.me | ||
``` | ||
--- | ||
|
||
## 示例输出 | ||
### 依赖安装 | ||
|
||
确保已安装 Python 3.x 版本。如果需要将脚本编译为 EXE,可以使用 PyInstaller: | ||
|
||
```bash | ||
$ python docker_pull.py alpine --arch arm64 --registry docker.xuanyuan.me | ||
[INFO] 开始下载镜像: alpine:latest (arm64) | ||
[INFO] 使用镜像源: docker.xuanyuan.me | ||
[INFO] 下载 manifest 文件... | ||
[INFO] 下载 config 文件... | ||
[INFO] 下载 layer 1/3: sha256:123456... | ||
[INFO] 下载 layer 2/3: sha256:abcdef... | ||
[INFO] 下载 layer 3/3: sha256:987654... | ||
[INFO] 打包镜像为 alpine_latest_arm64.tar... | ||
[INFO] 镜像下载完成: alpine_latest_arm64.tar | ||
pip install pyinstaller | ||
pyinstaller --onefile docker_image_puller.py | ||
``` | ||
|
||
--- | ||
## 使用 | ||
|
||
### 基本用法 | ||
|
||
```bash | ||
python docker_image_puller.py [镜像名称] [架构] [仓库地址] | ||
``` | ||
|
||
### 示例 | ||
|
||
## 注意事项 | ||
```bash | ||
D:\> DockerPull.exe | ||
|
||
欢迎使用 Docker 镜像拉取工具! | ||
请输入以下信息: | ||
请输入 Docker 镜像名称(例如:library/ubuntu:latest):alpine | ||
请输入架构(默认:amd64): | ||
请输入 Docker 仓库地址(默认:docker.xuanyuan.me): | ||
仓库地址:docker.xuanyuan.me | ||
仓库名:library/alpine | ||
标签:latest | ||
架构:amd64 | ||
Docker 镜像已拉取:library_alpine.tar | ||
``` | ||
|
||
1. 确保网络连接正常,尤其是访问 Docker Hub 或自定义镜像源时。 | ||
2. 如果下载速度较慢,建议使用国内镜像源(如 `docker.xuanyuan.me`)。 | ||
3. 下载的 `.tar` 文件可以通过 `docker load -i <file>.tar` 命令加载到本地 Docker 环境。 | ||
```bash | ||
python docker_image_puller.py library/ubuntu:latest amd64 docker.xuanyuan.me | ||
``` | ||
|
||
--- | ||
|
||
## 许可证 | ||
|
||
本项目基于 MIT 许可证开源。详情请参阅 [LICENSE](LICENSE) 文件。 | ||
本项目采用 MIT 许可证,详情见 [LICENSE](LICENSE) 文件。 | ||
|
||
## 联系方式 | ||
|
||
如有任何问题或建议,请通过 [GitHub Issues](https://github.com/topcss/docker-pull-tar/issues) 提出。 | ||
|
||
## 为什么选择这个工具? | ||
|
||
- **速度快**: 国内镜像源加速,下载更快。 | ||
- **架构灵活**: 支持多架构,适应各种环境。 | ||
- **易于使用**: 单文件脚本,无需复杂配置。 | ||
- **开放源代码**: 自由定制和扩展。 | ||
|
||
## 常见问题 | ||
|
||
--- | ||
**Q**: 如何配置国内镜像源? | ||
**A**: 在命令行中指定仓库地址参数,例如 `docker.xuanyuan.me`。 | ||
|
||
## 贡献 | ||
**Q**: 支持哪些架构? | ||
**A**: 目前支持 amd64 和 arm64 架构。 | ||
|
||
欢迎提交 Issue 或 Pull Request 以改进本工具! | ||
希望通过这个工具能为您的 Docker 镜像管理带来便利! 🚀 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@REM 删除多余文件 | ||
@REM rmdir dist /s /q | ||
rmdir build /s /q | ||
del DockerPull.exe.spec | ||
del Pipfile* | ||
|
||
@REM pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
为了减小打包的体积,需要在虚拟化环境中打包,以下为打包的步骤。 | ||
|
||
第一步 | ||
|
||
``` bat | ||
set WORKON_HOME=d:\.virtualenvs | ||
@REM 建立虚拟环境 | ||
pipenv install | ||
@REM 进入虚拟环境 | ||
pipenv shell | ||
``` | ||
|
||
第二步,虚拟环境需要单独执行,否则会报错 | ||
|
||
``` bat | ||
@REM 安装依赖,在虚拟环境中 | ||
pip install pyinstaller requests urllib3 -i https://pypi.tuna.tsinghua.edu.cn/simple/ | ||
@REM 打包 | ||
pyinstaller -F -n DockerPull.exe -i favicon.ico docker_image_puller.py | ||
@REM 卸载依赖 | ||
pipenv uninstall --all | ||
@REM 删除虚拟环境 | ||
pipenv --rm | ||
@REM 退出虚拟环境 | ||
exit | ||
``` |
Oops, something went wrong.