ドキュメントには頻繁に更新が加えられ、その都度公開されています。本ページの翻訳はまだ未完成な部分があることをご了承ください。最新の情報については、英語のドキュメンテーションをご参照ください。本ページの翻訳に問題がある場合はこちらまでご連絡ください。

Configuring Docker for use with GitHub Packages

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

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

ここには以下の内容があります:

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

OR, learn how to contribute.

Note: GitHub Packages is currently in beta for GitHub Enterprise Server 2.22. To join the beta for your instance, use the sign-up form.

Note: This package type may not be available for your instance, because site administrators can enable or disable each supported package type. 詳しい情報については、「Enterprise 向けのパッケージサポートを設定する」を参照してください。

About Docker and GitHub Packages

Note: The GitHub Packages Docker registry will be superseded by GitHub Container Registry in a future GitHub Enterprise release.

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

Before you can use the Docker registry on GitHub Packages, the site administrator for GitHub Enterprise Server インスタンス must enable Docker support and subdomain isolation for your instance. For more information, see "Managing GitHub Packages for your enterprise."

Authenticating to GitHub Packages

Note: The GitHub Packages Docker registry will be superseded by GitHub Container Registry in a future GitHub Enterprise release.

GitHub Packagesでパッケージを公開、インストール、削除するにはアクセストークンが必要です。 GitHub Packagesに直接、あるいはGitHub APIでユーザ名で認証を受けるのに、個人のアクセストークンが利用できます。 個人トークンを作成する際には、必要に応じて様々なスコープをトークンに割り当てできます。

To authenticate to GitHub Packages using a GitHub Actions workflow, you must use GITHUB_TOKEN.

Authenticating with a personal access token

GitHub Packages内でパッケージを公開及びインストールするためには、適切なスコープで個人アクセストークンを使わなければなりません。 詳しい情報については「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 docker.HOSTNAME -u USERNAME --password-stdin

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

For more information, see "Docker login."

Authenticating with the GITHUB_TOKEN

GitHub Actionsワークフローを使っているなら、GITHUB_TOKENを使い、個人アクセストークンを保存したり管理したりする必要なくGitHub Packages内のパッケージの公開や利用ができます。 詳しい情報については「GITHUB_TOKENでの認証」を参照してください。

Publishing a package

Note: The GitHub Packages Docker registry will be superseded by GitHub Container Registry in a future GitHub Enterprise release.

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

大文字はサポートされていないため、仮にGitHubのユーザあるいはOrganization名が大文字を含んでいても、リポジトリオーナーには小文字を使わなければなりません。

パッケージを公開した後は、GitHub上でそのパッケージを見ることができます。 詳しい情報については「パッケージの表示」を参照してください。

  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 GitHub Enterprise Server インスタンス, and VERSION with package version at build time.

    $ docker tag IMAGE_ID docker.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 GitHub Enterprise Server インスタンス, and PATH to the image if it isn't in the current working directory.s

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

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

Note: The GitHub Packages Docker registry will be superseded by GitHub Container Registry in a future GitHub Enterprise release.

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 Packages
$ 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 Packages
$ docker push docker.HOSTNAME/octocat/octo-app/monalisa:1.0

Installing a package

Note: The GitHub Packages Docker registry will be superseded by GitHub Container Registry in a future GitHub Enterprise release.

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,HOSTNAME with the host name of your GitHub Enterprise Server instance, and TAG_NAME with tag for the image you want to install. 大文字はサポートされていないため、仮にGitHubのユーザあるいはOrganization名が大文字を含んでいても、リポジトリオーナーには小文字を使わなければなりません。

$ docker pull docker.HOSTNAME/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

OR, learn how to contribute.