How do I add GitHub Container Registry images in my application?

The new GitHub Registry is different from the older GitHub Packages Docker registry (compare both here), and must be enabled before it can be used. To enable the GitHub registry feature for either personal or organization accounts, follow this guide.

Next, create a personal access token (PAT) that will allow traditional Docker login access to your new GitHub registry. To create a new PAT, follow this guide.

After those steps are done, authenticate to the GitHub registry and push a test image to verify that Docker login using the PAT works correctly.

NOTE: replace GITHUB_USERNAME with your GitHub ID

First, temporarily export the PAT token:

export CR_PAT=<YOUR_PAT_HERE>

Then authenticate to the GitHub registry:

echo $CR_PAT | docker login ghcr.io -u GITHUB_USERNAME --password-stdin

Next pull a small test image and push it to GitHub. This example uses NGINX:

docker pull nginx

Tag the NGINX image for GitHub:

docker tag nginx ghcr.io/GITHUB_USERNAME/nginx:latest

and push it to GitHub:

docker push ghcr.io/GITHUB_USERNAME/nginx:latest

If that works, simply configure the external registry in the Vendor Portal to use GitHub.

The private NGINX image just pushed to GitHub is now available in a deployment as ghcr.io/GITHUB_USERNAME/nginx

References:

1 Like