Comparing the Docker registry and the Container registry:
- The Container registry (
https://ghcr.io) offers improved performance for containers and will supercede the Docker registry in the future. - You can migrate your Docker images and workflows from the Docker registry (
docker.pkg.github.com) to the Container registry (https://ghcr.io) for granular permissions, container storage optimization, and more. For more information, see "Migrating to the Container registry from the Docker registry."
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 Packages
You need an access token to publish, install, and delete packages.
You can use a personal access token (PAT) to authenticate to GitHub Packages or the GitHub 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 Packages registry within a GitHub Actions workflow, you can use:
GITHUB_TOKENto publish packages associated with the workflow repository.- a PAT to install packages associated with other private repositories (which
GITHUB_TOKENcan't access).
For more information about GITHUB_TOKEN used in GitHub Actions workflows, see "Authentication in a workflow."
Authenticating with a personal access token
You must use a personal access token with the appropriate scopes to publish and install packages in GitHub Packages. For more information, see "About 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."
Publishing an image
Note: The GitHub Packages Docker registry is superseded by the Container registry, which offers improved container support. To learn how to migrate your existing Docker images and any workflows using them, see "Migrating to the Container registry from the Docker registry."
Note: Image names must only use lowercase letters.
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.
After you publish a package, you can view the package on GitHub. For more information, see "Viewing packages."
-
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 -
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 -
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 -
Publish the image to GitHub Packages.
$ docker push docker.pkg.github.com/OWNER/REPOSITORY/IMAGE_NAME:VERSIONNote: You must push your image using
IMAGE_NAME:VERSIONand not usingIMAGE_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 .
# Push the image to GitHub Packages
$ docker push docker.pkg.github.com/octocat/octo-app/monalisa:1.0
Downloading an image
Note: The GitHub Packages Docker registry is superseded by the Container registry, which offers improved container support. To learn how to migrate your existing Docker images and any workflows using them, see "Migrating to the Container registry from the Docker registry."
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.