Configuring Docker for use with GitHub Package Registry
You can configure the Docker client to use GitHub Package Registry to publish and retrieve docker images.
In this article
- Authenticating to GitHub Package Registry
- Publishing a package
- Receiving package registry events
- Installing a package
Authenticating to GitHub Package Registry
docker command, you can authenticate to GitHub Package Registry using either your GitHub username and password or your GitHub username and a personal access token with the
write:packages scopes. Your personal access token must also have the
repo scope when the repository is private.
Note: If you have two-factor authentication enabled, you must use a personal access token instead of a password. For more information, see "Creating a personal access token for the command line."
$ docker login docker.pkg.github.com -u USERNAME -p PASSWORD/TOKEN
Publishing a package
GitHub Package Registry supports multiple top-level Docker images per repository.
Determine the image name and ID for your docker image using the
$ docker images > < > > REPOSITORY TAG IMAGE ID CREATED SIZE > IMAGE_NAME VERSION IMAGE_ID 4 weeks ago 1.11MB >
Using the ID from the previous step, tag the docker image with the endpoint for the repository you want to push it to, the name of the image, and the version.
$ docker tag IMAGE_ID docker.pkg.github.com/OWNER/REPOSITORY/IMAGE_NAME:VERSION
Push the image to GitHub Package Registry:
$ docker push docker.pkg.github.com/OWNER/REPOSITORY/IMAGE_NAME:VERSION
You can access your packages from this URL by replacing
OWNERwith your GitHub user or organization name and
REPOSITORYwith your repository name:
For example, to push version 1.0 of an image called
monalisa to the
octocat/octo-app repository, the commands would be:
$ docker images > REPOSITORY TAG IMAGE ID CREATED SIZE > monalisa 1.0 c75bebcdd211 4 weeks ago 1.11MB # Tag the image with the OWNER/REPO/IMAGE_NAME format $ 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
Receiving package registry events
You can receive webhook events when a package is
updated. For more information, see "RegistryPackageEvent" in the GitHub Developer documentation.
Installing a package
You can install a docker image from GitHub Package Registry using the
docker pull command with the repository and tag name of the image.
$ docker pull docker.pkg.github.com/OWNER/REPOSITORY/IMAGE_NAME:TAG_NAME