Hallo, Entdecker! An dieser Seite wird aktiv gearbeitet, oder sie wird noch übersetzt. Die neuesten und genauesten Informationen findest Du in unserer englischsprachigen Dokumentation.

Configuring Docker for use with GitHub Packages

Sie können den Docker-Client für die Nutzung von GitHub Packages zum Veröffentlichen und Abrufen von Docker-Images konfigurieren.

GitHub Packages is available with GitHub Free, GitHub Pro, GitHub Free for organizations, GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server 2.22, GitHub One, and GitHub AE.


GitHub Packages ist nicht verfügbar für private Repositorys im Besitz von Konten mit älteren Pro-Repository-Plänen. GitHub Packages ist verfügbar mit GitHub Free, GitHub Pro, GitHub Free für Organisationen, GitHub Team, GitHub Enterprise Cloud, und GitHub One. For more information, see "[GitHub's products](/articles/github-s-products)."

Inhalt dieses Artikels

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

Bei GitHub Packages authentifizieren

Note: The GitHub Packages Docker registry now offers improved container support. For more information, see "About 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 "Container guides for GitHub Packages."

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

Bei GitHub Packages authentifizieren

You need an access token to publish, install, and delete packages. Du kannst ein persönliches Zugriffstoken verwenden, um Dich mit Deinem Benutzernamen direkt bei GitHub Packages oder beim GitHub-API zu authentifizieren. When you create a personal access token, you can assign the token different scopes depending on your needs.

To authenticate using a GitHub Actions-workflow:

  • For package registries (PACKAGE-REGISTRY.pkg.github.com), you can use a GITHUB_TOKEN.
  • For the container registry (ghcr.io/OWNER/IMAGE-NAME), you can use a GITHUB_TOKEN or a personal access token. We strongly recommend you use a GITHUB_TOKEN to avoid unncessary access to your repositories.

For more information about GITHUB_TOKEN used in GitHub Actions workflows, see "Encrypted secrets" and "Authentication in a workflow."

Authenticating with a personal access token

Du musst ein persönliches Zugriffstoken mit dem entsprechenden Geltungsbereich verwenden, um Pakete in GitHub Packages zu veröffentlichen und zu installieren. Weitere Informationen findest Du unter „Über GitHub Packages."

You can authenticate to GitHub Packages 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

Wenn Du einen GitHub Actions-Workflow verwendest, kannst Du einen GITHUB_TOKEN verwenden, um Pakete in GitHub Packages zu veröffentlichen und zu konsumieren, ohne einen persönlichen Zugriffstoken speichern und verwalten zu müssen. Weitere Informationen findest Du unter „Authentifizieren mit dem GITHUB_TOKEN."

Publishing an image

Note: The GitHub Packages Docker registry now offers improved container support. For more information, see "About 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 "Container guides for GitHub Packages."

Note: Image names must only use lowercase letters.

GitHub Packages unterstützt mehrere Top-Level-Docker-Images pro 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.

Nachdem Du ein Paket veröffentlicht hast, kannst Du das Paket auf GitHub ansehen. Weitere Informationen findest Du unter „Anzeigen von Paketen."

  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. 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.

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

    $ 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

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 Packages
$ 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 .

# Pusht das Image zu GitHub Packages
$ docker push docker.pkg.github.com/octocat/octo-app/monalisa:1.0

Downloading an image

Note: The GitHub Packages Docker registry now offers improved container support. For more information, see "About 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 "Container guides for GitHub Packages."

You can use the docker pull command to install a docker image from GitHub Packages, 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.

$ 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.

Weiterführende Informationen

Did this doc help you?

Privacy policy

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

Oder, learn how to contribute.