Skip to main content
Publicamos atualizações frequentes em nossa documentação, e a tradução desta página ainda pode estar em andamento. Para obter as informações mais recentes, acesse a documentação em inglês. Se houver problemas com a tradução desta página, entre em contato conosco.

Esta versão do GitHub Enterprise foi descontinuada em 2022-06-03. Nenhum lançamento de patch será feito, mesmo para questões críticas de segurança. Para obter melhor desempenho, melhorar a segurança e novos recursos, upgrade to the latest version of GitHub Enterprise. Para ajuda com a atualização, contact GitHub Enterprise support.

Working with the Docker registry

You can push and pull your Docker images using the GitHub Package Registry Docker registry.

GitHub Package Registry is available with GitHub Free, GitHub Pro, GitHub Free for organizations, GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server 3.0 or higher, and GitHub AE. For more information about upgrading your GitHub Enterprise Server instance, see "About upgrades to new releases" and refer to the Upgrade assistant to find the upgrade path from your current release version.

Nota: Este tipo de pacote pode não estar disponível para sua instância, porque os administradores do site podem habilitar ou desabilitar cada tipo de pacote compatível. Para obter mais informações, consulte "Configurar pacotes de suporte para a sua empresa".

About Docker support

When installing or publishing a Docker image, the Docker registry does not currently support foreign layers, such as Windows images.

Authenticating to GitHub Package Registry

You need an access token to publish, install, and delete packages.

You can use a personal access token (PAT) to authenticate to GitHub Package Registry or the GitHub Enterprise Server API. When you create a personal access token, you can assign the token different scopes depending on your needs. For more information about packages-related scopes for a PAT, see "About permissions for GitHub Packages."

To authenticate to a GitHub Package Registry registry within a GitHub Actions workflow, you can use:

  • GITHUB_TOKEN to publish packages associated with the workflow repository.
  • a PAT to install packages associated with other private repositories (which GITHUB_TOKEN can't access).

Para obter mais informações sobre GITHUB_TOKEN usado nos fluxos de trabalho de GitHub Actions, consulteAutenticação em um fluxo de trabalho".

Authenticating with a personal access token

Você deve usar um token de acesso pessoal com os escopos apropriados para publicar e instalar pacotes no GitHub Package Registry. Para obter mais informações, consulte "Sobre GitHub Package Registry."

You can authenticate to GitHub Package Registry with Docker using the docker login command.

To keep your credentials secure, we recommend you save your personal access token in a local file on your computer and use Docker's --password-stdin flag, which reads your token from a local file.

If your instance has subdomain isolation enabled:

$ cat ~/TOKEN.txt | docker login docker.HOSTNAME -u USERNAME --password-stdin

If your instance has subdomain isolation disabled:

$ cat ~/TOKEN.txt | docker login HOSTNAME -u USERNAME --password-stdin

To use this example login command, replace USERNAME with your GitHub Enterprise Server username, HOSTNAME with the URL for your GitHub Enterprise Server instance, and ~/TOKEN.txt with the file path to your personal access token for GitHub Enterprise Server.

For more information, see "Docker login."

Publishing an image

Observação: O GitHub Package Registry Registro do Docker será substituído no futuro GitHub Enterprise Server pelo Container registry, que oferece suporte melhorado para o contêiner.

Note: Image names must only use lowercase letters.

GitHub Package Registry supports multiple top-level Docker images per repository. A repository can have any number of image tags. You may experience degraded service publishing or installing Docker images larger than 10GB, layers are capped at 5GB each. For more information, see "Docker tag" in the Docker documentation.

Após publicar um pacote, você poderá visualizá-lo no GitHub. Para obter mais informações, consulte "Visualizar pacotes".

  1. Determine the image name and ID for your docker image using docker images.

    $ docker images
    > <� >
    > REPOSITORY        TAG        IMAGE ID       CREATED      SIZE
    > IMAGE_NAME        VERSION    IMAGE_ID       4 weeks ago  1.11MB
  2. Using the Docker image ID, tag the docker image, replacing OWNER with the name of the user or organization account that owns the repository, REPOSITORY with the name of the repository containing your project, IMAGE_NAME with name of the package or image, HOSTNAME with the hostname of your GitHub Enterprise Server instance, and VERSION with package version at build time.

    If your instance has subdomain isolation enabled:

    $ docker tag IMAGE_ID docker.HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:VERSION

    If your instance has subdomain isolation disabled:

    $ docker tag IMAGE_ID HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:VERSION
  3. If you haven't already built a docker image for the package, build the image, replacing OWNER with the name of the user or organization account that owns the repository, REPOSITORY with the name of the repository containing your project, IMAGE_NAME with name of the package or image, VERSION with package version at build time, HOSTNAME with the hostname of your GitHub Enterprise Server instance, and PATH to the image if it isn't in the current working directory.

    If your instance has subdomain isolation enabled:

    $ docker build -t docker.HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:VERSION PATH

    If your instance has subdomain isolation disabled:

    $ docker build -t HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:VERSION PATH
  4. Publish the image to GitHub Package Registry.

    If your instance has subdomain isolation enabled:

    $ docker push docker.HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:VERSION

    If your instance has subdomain isolation disabled:

    $ docker push HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:VERSION

    Note: You must push your image using IMAGE_NAME:VERSION and not using IMAGE_NAME:SHA.

Example publishing a Docker image

These examples assume your instance has subdomain isolation enabled.

You can publish version 1.0 of the monalisa image to the octocat/octo-app repository using an image ID.

$ docker images

> REPOSITORY           TAG      IMAGE ID      CREATED      SIZE
> monalisa             1.0      c75bebcdd211  4 weeks ago  1.11MB

# Tag the image with OWNER/REPO/IMAGE_NAME
$ docker tag c75bebcdd211 docker.HOSTNAME/octocat/octo-app/monalisa:1.0

# Push the image to GitHub Package Registry
$ docker push docker.HOSTNAME/octocat/octo-app/monalisa:1.0

You can publish a new Docker image for the first time and name it monalisa.

# Build the image with docker.HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:VERSION
# Assumes Dockerfile resides in the current working directory (.)
$ docker build -t docker.HOSTNAME/octocat/octo-app/monalisa:1.0 .

# Push the image to GitHub Package Registry
$ docker push docker.HOSTNAME/octocat/octo-app/monalisa:1.0

Downloading an image

Observação: O GitHub Package Registry Registro do Docker será substituído no futuro GitHub Enterprise Server pelo Container registry, que oferece suporte melhorado para o contêiner.

You can use the docker pull command to install a docker image from GitHub Package Registry, replacing OWNER with the name of the user or organization account that owns the repository, REPOSITORY with the name of the repository containing your project, IMAGE_NAME with name of the package or image, HOSTNAME with the host name of your GitHub Enterprise Server instance, and TAG_NAME with tag for the image you want to install.

If your instance has subdomain isolation enabled:

$ docker pull docker.HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:TAG_NAME

If your instance has subdomain isolation disabled:

$ docker pull HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:TAG_NAME

Note: You must pull the image using IMAGE_NAME:VERSION and not using IMAGE_NAME:SHA.