GithubAnnouncement

Ever wondered to have your source code and packages in one place?

GitHub Package Registry is a package management service that makes it easy to publish public or private packages next to your source code. It is fully integrated with GitHub, so you can use the same search, browsing, and management tools to find and publish packages as you do for your repositories. You can also use the same user and team permissions to manage code and packages together.

It supports familiar package management tools:

  • JavaScript (npm)
  • Java (Maven)
  • Ruby (RubyGems),
  • .NET (NuGet)
  • Docker images

Authenticating to GitHub Package Registry

You can use the docker cli to use GitHub Package Registry to publish and retrieve docker images.

1
$ docker login docker.pkg.github.com -u sujaypillai -p

Publishing a package (docker image)

Let’s try to build the docker image for the repository - buildxdemo which has a Dockerfile within the project. After checking out the project execute the docker build

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
$ docker build -t docker.pkg.github.com/sujaypillai/buildxdemo/demo . 
Sending build context to Docker daemon   98.3kB
Step 1/6 : FROM golang AS build
---> c4d6fdf2260a
....
Step 6/6 : CMD ["/hello"]
---> Using cache
---> 38c5db73c5a7
Successfully built 38c5db73c5a7
Successfully tagged docker.pkg.github.com/sujaypillai/buildxdemo/demo:latest

The tagging of the image should follow the below pattern -

1
docker.pkg.github.com/owner/repository/image_name:version

Because upper case letters aren’t supported, you must use lowercase letters for the repository owner even if the GitHub user or organization name contains uppercase letters. GitHub Package Registry supports multiple top-level Docker images per repository.

Push the image to GitHub Package Registry:

1
2
3
4
5
6
$ docker push docker.pkg.github.com/sujaypillai/buildxdemo/demo
The push refers to repository [docker.pkg.github.com/sujaypillai/buildxdemo/demo]
bf1eeaedd583: Layer already exists
latest: digest: sha256:c8ddfad1bfe68db341bc34d1cbe1f093de1eb8b73463396c67603934d8e49d46 size: 528
03f6ad6134dc: Layer already exists
v1: digest: sha256:b9ce4d4b077075e698c37a99f3e0a54d43d5583e164c6b493ad25a7f467edc40 size: 528

You can access your packages from this URL by replacing OWNER with your GitHub user or organization name and REPOSITORY with your repository name:

1
https://github.com/OWNER/REPOSITORY/packages
i.e. https://github.com/sujaypillai/buildxdemo/packages and it should look similar to - GithubPackageRegistry

Package Insights

GithubPackageRegistryInsights Docker images hosted on GitHub include details and download statistics, along with their entire history, reference command to pull image from command line and the instruction to use it as base image in Dockerfile.

As Github package registry doesn’t support Image Manifest v2,Schema 2 it doesn’t support multi-arc docker images. Below is the error what I got when trying to build a multi-arc docker image using buildx and push to Github package registry - GithubPackageRegistryNoSupportForImageManifestv2

Please upvote this issue on GitHub if you would love to see multi-arc docker image support on Github package registry.