Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.

Connecting a repository to a container image

You can link a repository with a container image locally and on GitHub.

Paquetes de GitHub is available with GitHub Free, GitHub Pro, GitHub Free for organizations, GitHub Team, GitHub Enterprise Cloud, Servidor de GitHub Enterprise 2.22, and GitHub One.


Paquetes de GitHub no está disponible para repositorios privados que pertenezcan a cuentas que utilicen planes tradicionales por repositorio. Paquetes de GitHub se encuentra disponible con GitHub Free, GitHub Pro, GitHub Free para organizaciones, GitHub Team, GitHub Enterprise Cloud, y GitHub One. Para obtener más información, consulta la sección "Productos de GitHub".

En este artículo

¿Te ayudó este documento?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

O, learn how to contribute.

When you link a container image with a repository, the package landing page will show information and links from the repository, such as the README.

To connect a repository and a container image on GitHub, they must share the same owner on GitHub. For example, both my_repo and hello_docker are owned by the user monalisa:

https://github.com/monalisa/my_repo
https://github.com/monalisa/hello_docker

Connecting a repository to a user-owned container image on GitHub

  1. On GitHub, navigate to the main page of your user account.

  2. En la esquina superior derecha de GitHub, da clic en tu foto de perfil, posteriormente, da clic en Tu perfil.

    Foto de perfil

  3. On your profile page, in the top right, click Packages.

    Packages option on profile page

  4. Search for and select your package.

  5. In the top right of your container image's landing page, click Package settings.

    Package settings button

  6. Under your package versions, click Connect repository.

    Connect a repository button on packages landing page

  7. Select a repository, then click Connect repository.

    Connect a repository button in repository selection pop-up window

Connecting a repository to an organization-owned container image on GitHub

  1. On GitHub, navigate to the main page of your organization.

  2. Under your organization name, click Packages.

    Container access invite button

  3. Search for and select your package.

  4. In the top right of your container image's landing page, click Package settings.

    Package settings button

  5. Under your package versions, click Connect repository.

    Connect a repository button on packages landing page

  6. Select a repository, then click Connect repository.

    Connect a repository button in repository selection pop-up window

Connecting a repository to a container image on the command line

  1. In your Dockerfile, add this line, replacing OWNER and REPO with your details:

    LABEL org.opencontainers.image.source https://github.com/OWNER/REPO

    For example, if you're the user monalisa and own my-repo, you would add this line to your Dockerfile:

    LABEL org.opencontainers.image.source https://github.com/monalisa/my-repo

    For more information, see "LABEL" in the official Docker documentation and "Pre-defined Annotation Keys" in the opencontainers/image-spec repository.

  2. Build your container image. This example builds an image from the Dockerfile in the current directory and assigns the image name hello_docker.

    $ docker build -t hello_docker .
  3. Optionally, review details for the Docker image you want to tag.

    $ docker images
    > REPOSITORY                                            TAG                 IMAGE ID            CREATED             SIZE
    > ghcr.io/my-org/hello_docker         latest              38f737a91f39        47 hours ago        91.7MB
    > ghcr.io/my-username/hello_docker    latest              38f737a91f39        47 hours ago        91.7MB
    > hello-world                                           latest              fce289e99eb9        16 months ago       1.84kB
  4. Tag your Docker image with your desired image name and hosting destination.

    $ docker tag IMAGE_NAME ghcr.io/OWNER/NEW_IMAGE_NAME:TAG

    Por ejemplo:

    $ docker tag 38f737a91f39 ghcr.io/monalisa/hello_docker:latest
  5. If you haven't already, authenticate to GitHub Container Registry. For more information, see "Authenticating to GitHub Container Registry."

    $ echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
    > Login Succeeded
  6. Push your container image to GitHub Container Registry.

    $ docker push ghcr.io/OWNER/IMAGE-NAME:TAG

    Por ejemplo:

    $ docker push ghcr.io/monalisa/hello_docker:latest

¿Te ayudó este documento?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

O, learn how to contribute.