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

Abierto
#7,400 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
docker, go
Área
cli

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
6.1k
Forks
2.2k
Merge medio
1 d 8 h
PR fusionados (30 d)
62

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de docker/cli

Todos los issues de docker/cli

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.