GitHub recently released the GitHub Docker Container Registry, a competitor to the default Docker Hub that allows you to privately store Docker images in the cloud. It functions as an extension of GitHub packages, and integrates with their existing CI/CD tooling.
What Is GitHub Container Registry?
Docker container registries store built versions of Docker containers. The default one is the Docker Hub, which hosts most open-source Docker containers. However, you’re entirely free to use a different repository, and many businesses will choose to use a private registry.
GitHub is in a particularly good spot to offer a container registry, being the home for free and open-source software, and it’s actually surprising that it took them this long to bring one to market. But it’s here now, and integrates pretty well with their existing services, making it one of the best competitors to the Docker Hub available today.
The container registry operates as an extension of GitHub Packages, a package repository for package managers like NPM and NuGet. All they’re adding is an option to use it for Docker images as well as support for Docker CLI tooling like
The source code for the images, including the Dockerfile, is all stored in a standard GitHub repository. Then, when you want to push an image, you can build it and push it to the associated packages for that repo.
With the source code and Docker image both being on GitHub, it presents a unique opportunity for integration. GitHub Actions can be triggered from source code changes, which can automatically run builds of your image when changes are committed to GitHub.
During the Container Registry beta, the container registry will be free to use. Open-source and public repositories are always entirely free to use, but private repositories will fall under the standard billing rates for GitHub Packages after the beta is over. The free tier of that includes 500 MB of storage and 1 GB of transfer every month, which should be adequate for most projects. If it’s not, you can invest in GitHub Teams or GitHub Enterprise.
How Do You Use It?
The URL for the new registry is
ghcr.io, easy to remember and short to type, which is a must when you have to type it out for every Docker command.
To get started, you’ll first need to generate a personal access token from Settings > Developer Settings > Personal Access Tokens.
Then, you can login to the registry using that token. Technically, GitHub recommends putting this in a file and passing it in STDIN through
cat, but pasting it is fine.
docker login ghcr.io -u username
Then, run a standard Docker build, tag it with the repo URL and repository name, and push the image.
docker build . -t ghcr.io/username/repository/image:version docker push ghcr.io/username/repository/image:version
Note, you will need an actual Git repository to associate this package with.
After it’s pushed, you should see a new package on your profile, or listed under “Packages” on the repository.
One of the best things you can do from here is set up an automatic CI/CD pipeline that will build your Docker image whenever changes are detected in Git. GitHub has a prebuilt action called “Publish Docker Container” that will publish to the package registry for the repository.
If you’d like to get started, you can read our guide to setting it up to learn more.
- › You Can Now Get Proton Calendar on Your iPhone
- › Google Chrome Has a New Search Sidebar: Here’s How to Use It
- › What is File Versioning, and Do You Need It?
- › How to Add Travel Time to a Google Calendar Event
- › Microsoft Now Sells Tiny Hoodies for Cold Xbox Controllers
- › How to Add or Remove a Secondary Axis in an Excel Chart