Feature request: Choose public or private visibility when pushing a new repository to Docker Hub

未关闭
#7,400 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start with the related discussion in issue #4977 and review Docker Hub’s repository creation API, especially its is_private field. The payload names no CLI files or tests, so first locate the docker push command and its registry handling. Done means new Docker Hub repositories use the requested visibility before upload, mismatches and failures stop the push, and other registries are clearly handled.

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

描述

Description

When running docker push for a Docker Hub repository that does not yet exist, Docker Hub creates it using the namespace's default repository visibility.

If that default is public, a user intending to upload a private image can accidentally publish it. The CLI does not offer a public/private selection before uploading.

I would like an option to explicitly select the intended visibility when pushing to a new Docker Hub repository.

Steps illustrating the current behavior
  1. Use a Docker Hub namespace whose default repository visibility is Public.

  2. Tag a local image with a repository name that does not exist:

    docker tag myapp:latest <username>/new-repository:latest
    
  3. Push the image:

    docker push <username>/new-repository:latest
    
  4. Check the newly created repository's visibility in Docker Hub.

The repository is created as public according to the namespace default, without a visibility selection in the CLI.

Proposed behavior

Allow users to explicitly select visibility before the first upload. For example, the following is proposed syntax, not an existing option:

docker push --visibility private <username>/new-repository:latest
docker push --visibility public <username>/new-repository:latest

An optional interactive mode could offer:

Choose visibility for the new Docker Hub repository:
> Private
  Public

Automation should be able to use the explicit flag without any interactive prompt. Existing command behavior should remain unchanged when the feature is not requested.

Expected safeguards
  • Create a missing repository with the requested visibility before uploading any image content.
  • Verify the repository's visibility before pushing, and stop if verification or creation fails, including permission or private-repository quota errors.
  • For an existing repository, report a visibility mismatch rather than silently changing its visibility.
  • Clearly report unsupported registries if this functionality is specific to Docker Hub.
Implementation consideration

Repository visibility is managed by Docker Hub rather than the standard image-push protocol. This may require Docker Hub API integration or a dedicated CLI plugin. A check before uploading also cannot prevent another authorized actor from changing repository visibility concurrently or afterward.

References and related discussion

This request overlaps with #4977; I am linking it to preserve the existing discussion and implementation constraints.

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

环境准备

从这里开始

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

docker/cli 的其他 Issue

查看 docker/cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

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