Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Add option to docker pull to use local cache first without contacting Docker Hub

未关闭
#6,082 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
docker, go
领域
cli

调研方向

从 docker pull 的 CLI 入口点开始,跟踪该命令如何处理本地可用的镜像以及与 registry 的联系。定义缓存镜像和未缓存镜像的行为,然后验证当镜像在本地可用时,新选项会跳过 registry,而在镜像不可用时仍会执行 pull。

由索引模型根据 Issue 内容生成。

描述

kind/feature status/0-triage
Description

Currently, docker pull contacts Docker Hub (or another registry), even when the requested image is already present locally and up to date. This behavior:

  • Triggers unauthenticated rate limits unnecessarily.
  • Makes it unsafe to use docker pull in CI environments without Docker Hub authentication.

Please consider adding a flag to docker pull that checks the local image cache first and skips contacting the registry if the image is already available locally.

Worst of all, docker pull is currently inconsistent—it sometimes succeeds and sometimes fails, even when the image is already cached locally.

Here is an example where both images are present locally:

Pulling atlassian/bamboo-server
  docker pull atlassian/bamboo-server
  Using default tag: latest
  latest: Pulling from atlassian/bamboo-server
  Digest: sha256:b3d33daee6667c15ae3f1a9225bd85f493a23183f4d33776aa7243822d0fa820
  Status: Image is up to date for atlassian/bamboo-server:latest
  docker.io/atlassian/bamboo-server:latest

Pulling buildkite/agent
  docker pull buildkite/agent
  Using default tag: latest
  Error response from daemon: toomanyrequests: You have reached your unauthenticated pull rate limit. https://www.docker.com/increase-rate-limit

A common workaround is to explicitly check for the image before pulling:

if ! docker image inspect ubuntu:22.04 > /dev/null 2>&1; then
    docker pull ubuntu:22.04
fi

Alternatively, pulling by digest avoids the registry check:

docker pull ubuntu@sha256:<digest>

But these approaches are manual and error-prone. A built-in option (e.g. --check-cache-first) would offer a simpler and more robust solution for both local workflows and CI pipelines.

主要语言
Go
星标
6.1k
派生
2.2k
平均合并
1 天 11 小时
30 天内合并 PR
45

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker/cli 的其他 Issue

查看 docker/cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。