Docker Support for the New GitHub Container Registry

Docker and GitHub continue to work together to make life easier for developers. GitHub today announced a new container registry: GitHub Container Registry. GitHub and Docker both occupy essential components in the developer workflow for building and deploying cloud native applications so we thought we would provide some insight into how the new tooling benefits developers. 

Dockergithub

Found at ghcr.io, the new GitHub registry adds support for anonymous pulls and decouples git repositories permissions from container registry’s permissions. This allows projects to have private git repositories with a public container registry or vice versa. Other features like OCI compliance, Helm charts, and support for GITHUB_TOKEN are expected later. 

The GitHub Container Registry was built with Docker in mind so your Docker Engines and Docker Desktops will seamlessly work with this new registry.  Let’s take a look at this in action over at our upcoming Docker Login GitHub Action:

name: ci
on:
  push:
    branches: master
jobs:
  login:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/[email protected]
      -
        name: Login to GitHub Package Registry
        uses: docker/[email protected]
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GHCR_TOKEN }}

That is all you need to do. When you compare this against the the job for a GitHub packages repository you just needed to update two lines:

  • registry: docker.pkg.github.com becomes registry: ghcr.io Fourteen fewer characters to type, FTW.
  • password: ${{ secrets.GITHUB_TOKEN }} becomes password: ${{ secrets.GHCR_TOKEN }}. Unfortunately what this means is the automatically generated GITHUB_TOKEN will not work for authentication for the initial release. You will have to go to GitHub, generate a personal access token, and create a GitHub Action secret. You can read more about this in the documentation here. We believe that GITHUB_TOKEN support will be released later.

Once that is done you are ready to go. You can continue on to docker build and docker push to your heart’s content. There are lots of different use cases across the container lifecycle.  For a more complete example from CI to production, using both GitHub Container Registry and Docker Hub, including a bonus preview of our upcoming Docker Buildx action, go to my example repository. 

From the 11 billion images pulled a month to the 7 million developers Docker Hub will always be there for the developer. Portability and choice have always been core to the Docker experience. We are always excited to work with our friends at GitHub to make the best possible experience for our customers, users, and community. 

If you are ready to get started with Docker, we offer free plans for individual developers and teams just starting out. Get started with Docker today.

Feedback

0 thoughts on "Docker Support for the New GitHub Container Registry"