Using the new GitHub Container Registry with Codefresh
Tags: github, container, devops, docker
Published: 2020-10-22 14:04:21

The GitHub Container Registry <a href="https://github.blog/2020-09-01-introducing-github-container-registry/">has just been announced</a> by GitHub and is supported natively on Codefresh like any other Docker repository.

Codefresh provides multiple options to connect to Docker Container Registries, one of which is GitHub Container Registries. Currently, GitHub plans to include the GitHub Container Registry within the pricing model of GitHub packages. In comparison, Docker Hub has added <a href="https://www.docker.com/blog/scaling-docker-to-serve-millions-more-developers-network-egress/">rate limits</a> to free accounts. Thus, the GitHub Container Registry is an alternative for storing your public and private Docker images.

Additionally, you are able to define container privacy settings independent of connected Git repositories. In some cases, the repository might be private, whereas the container could be public or accessible at a team or organizational level.

## Using the GitHub Container Registry from the Docker CLI

This post is going to focus on the GitHub Container Registry. However, as part of <a href="https://github.com/features/packages">GitHub Packages</a>, GitHub’s storage solution supports several other kinds of artifacts, such as npm or Maven.

The image URL for images stored in the GitHub Container registry is the following:

<code>ghcr.io/github-account/image-name:image-version</code>

The <a href="https://docs.github.com/en/free-pro-team@latest/packages/getting-started-with-github-container-registry/about-github-container-registry">GitHub documentation</a> describes how you can tag and push your Container images to the GitHub Container Registry from the Docker CLI. Alternatively, you can use the GitHub Container Registry as a Docker Registry in your Codefresh pipeline to automate the process.

## Automating Image Pushes to the GitHub Container Registry with Codefresh

When setting up a registry, you can choose between Amazon ECR, Docker Hub, Google Container Registry (etc.), or other registries. Simply select “Other Registries” to connect your Codefresh pipeline with your GitHub Container Registry. Registry integrations are just one of many integrations that Codefresh has. We also integrate with Slack, Kubernetes, Helm Repositories, and more.

If you have already been using GitHub Docker Packages, we suggest you remove the old Docker registry, which used GitHub Docker Packages, and add a new registry entry for the new Github Container Registry. Make sure you use the right domain for the GitHub Container Registry: ghcr.io

<a href="https://codefresh.io/wp-content/uploads/2020/10/registry.png"><img class="size-full wp-image-17743" src="https://codefresh.io/wp-content/uploads/2020/10/registry.png" alt="Docker Registry" width="1600" height="807" /></a>

That’s it! Once the integration is in place, you can use the Github Container Registry in any <a href="https://codefresh.io/docs/docs/configure-ci-cd-pipeline/introduction-to-codefresh-pipelines/">Codefresh pipeline</a> as shown below.

<a href="https://codefresh.io/wp-content/uploads/2020/10/codefresh-pipeline.png"><img class="size-full wp-image-17744" src="https://codefresh.io/wp-content/uploads/2020/10/codefresh-pipeline.png" alt="Codefresh Pipeline" width="1600" height="831" /></a>

After you run the pipeline, your Docker images will be automatically pushed to the GitHub Container Registry. Once done, they will become visible in the GitHub Packages UI. You can access the image specifications either with the <a href="https://codefresh.io/docs/docs/ci-cd-guides/working-with-docker-registries/#viewing-docker-images">Image Dashboard</a> in your Codefresh account or through the GitHub UI like shown in the following screenshots.

In Codefresh Images:

<a href="https://codefresh.io/wp-content/uploads/2020/10/codefresh-images.png"><img class="size-full wp-image-17742" src="https://codefresh.io/wp-content/uploads/2020/10/codefresh-images.png" alt="Codefresh Images" width="1383" height="382" /></a>

Under GitHub Packages:

<a href="https://codefresh.io/wp-content/uploads/2020/10/github-packages.png"><img class="size-full wp-image-17740" src="https://codefresh.io/wp-content/uploads/2020/10/github-packages.png" alt="GitHub Packages" width="918" height="268" /></a>

Opening the Docker image in the GitHub UI allows you to modify the image permissions and connect your image to an existing repository like displayed below:

<a href="https://codefresh.io/wp-content/uploads/2020/10/ghcr.png"><img class="size-full wp-image-17739" src="https://codefresh.io/wp-content/uploads/2020/10/ghcr.png" alt="GitHub Container Registry" width="978" height="766" /></a> The image in the GitHub Container Registry

## Getting started with GitHub Container Registry in Codefresh

We made it super easy for you to connect GitHub Container Registry to your Codefresh pipeline. You can find more details in the <a href="https://codefresh.io/docs/docs/integrations/docker-registries/github-container-registry/">Codefresh documentation</a>.

Wait, you are not a Codefresh user yet?

This process works on all Codefresh accounts. You can set it up in minutes to try it out.

If you have any questions, feel free to ask in <a href="https://community.codefresh.io/">our community forum</a>, we would love to hear from you.

<a href="https://codefresh.io/codefresh-signup/?utm_source=Blog&amp;utm_medium=Post&amp;utm_campaign=githubregistry">Create Your Free Account today</a>!