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.

Configuring Docker for use with GitHub Packages

You can configure the Docker client to use GitHub Package Registry to publish and retrieve docker images.

GitHub Package Registry está disponível com GitHub Free, GitHub Pro, GitHub Free para organizações, GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server 2.22, e GitHub One.


O GitHub Package Registry não está disponível para repositórios privados de contas que utilizam planos antigos por-repositório. GitHub Package Registry está disponível com GitHub Free, GitHub Pro, GitHub Free para organizações, GitHub Team, GitHub Enterprise Cloud e GitHub One. Para obter mais informações, consulte "[produtos de GitHub](/articles/github-s-products)

Neste artigo

Did this doc help you?

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

Ou, learn how to contribute.

About Docker and GitHub Package Registry

Note: The GitHub Package Registry Docker registry will be superseded by GitHub Container Registry. To learn how to migrate your existing Docker images and any workflows using them, see "Migrating to GitHub Container Registry for Docker images" and "Getting started with GitHub Container Registry."

When installing or publishing a docker image, GitHub Package Registry does not currently support foreign layers, such as Windows images.

Authenticating to GitHub Package Registry

Note: The GitHub Package Registry Docker registry will be superseded by GitHub Container Registry. To learn how to migrate your existing Docker images and any workflows using them, see "Migrating to GitHub Container Registry for Docker images" and "Getting started with GitHub Container Registry."

Você precisa de um token de acesso para publicar, instalar e excluir pacotes no GitHub Package Registry. Você pode usar um token de acesso pessoal para autenticar com seu nome de usuário diretamente no GitHub Package Registry ou na API GitHub. Ao criar um token de acesso pessoal, você pode atribuir diferentes escopos de token, dependendo da sua necessidade.

Para efetuar a autenticação usando um fluxo de trabalho do GitHub Actions:

  • Para registros de pacotes (PACKAGE-REGISTRY.pkg.github.com/OWNER/REPOSITORY/IMAGE-NAME), você pode usar um GITHUB_TOKEN.
  • Para o registro do contêiner (ghcr.io/OWNER/IMAGE-NAME), você deve usar um token de acesso pessoal.

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.

$ cat ~/TOKEN.txt | docker login https://docker.pkg.github.com -u USERNAME --password-stdin

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

For more information, see "Docker login."

Authenticating with the GITHUB_TOKEN

Se você estiver utilizando um fluxo de trabalho do GitHub Actions, você pode usar um GITHUB_TOKEN para publicar e consumir pacotes em GitHub Package Registry sem precisar armazenar e gerenciar um token de acesso pessoal. Para obter mais informações, consulte "Authenticating with the GITHUB_TOKEN."

Publishing a package

Note: The GitHub Package Registry Docker registry will be superseded by GitHub Container Registry. To learn how to migrate your existing Docker images and any workflows using them, see "Migrating to GitHub Container Registry for Docker images" and "Getting started with GitHub Container Registry."

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.

Como não é permitido usar letras maiúsculas, é preciso usar letras minúsculas no nome do proprietário do repositório, mesmo que o nome do usuário ou da organização no GitHub contenha letras maiúsculas.

Após publicar um pacote, você poderá visualizá-lo no GitHub. For more information, see the "package webhook event."

  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, and VERSION with package version at build time.

    $ docker tag IMAGE_ID docker.pkg.github.com/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, and PATH to the image if it isn't in the current working directory.s

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

    $ docker push docker.pkg.github.com/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

Note: The GitHub Package Registry Docker registry will be superseded by GitHub Container Registry. To learn how to migrate your existing Docker images and any workflows using them, see "Migrating to GitHub Container Registry for Docker images" and "Getting started with GitHub Container Registry."

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.pkg.github.com/octocat/octo-app/monalisa:1.0

# Push the image to GitHub Package Registry
$ docker push docker.pkg.github.com/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.pkg.github.com/OWNER/REPOSITORY/IMAGE_NAME:VERSION
# Assumes Dockerfile resides in the current working directory (.)
$ docker build -t docker.pkg.github.com/octocat/octo-app/monalisa:1.0 .

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

Installing a package

Note: The GitHub Package Registry Docker registry will be superseded by GitHub Container Registry. To learn how to migrate your existing Docker images and any workflows using them, see "Migrating to GitHub Container Registry for Docker images" and "Getting started with GitHub Container Registry."

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, and TAG_NAME with tag for the image you want to install. Como não é permitido usar letras maiúsculas, é preciso usar letras minúsculas no nome do proprietário do repositório, mesmo que o nome do usuário ou da organização no GitHub contenha letras maiúsculas.

$ docker pull docker.pkg.github.com/OWNER/REPOSITORY/IMAGE_NAME:TAG_NAME

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

Further reading

Did this doc help you?

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

Ou, learn how to contribute.