Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

▶️ Video Course Sale - Get Video Courses as LOW as $6.99 USD each only!

GitHub Container Registry

Home » Others » GitHub Container Registry

GitHub Container Registry

GitHub Container Registry Cheat Sheet

  • Store, manage, and distribute Docker & OCI container images.
  • Seamlessly works with GitHub repositories, GitHub Actions, and fine-grained access controls.
  • Supported Formats:
    • Docker Image Manifest V2, Schema 2
    • Open Container Initiative (OCI) specifications
  • Tutorials dojo strip

Features

  • You can host and manage container images directly in GitHub.
  • Access can be controlled either by linking to repository permissions or by defining granular package-level permissions.
  • Authentication can be performed using either GITHUB_TOKEN (for workflows in the same repo) or a Personal Access Token (classic) with the appropriate scopes.
  • Public images can be pulled anonymously without authentication.
  • GitHub Actions can automate builds, tests, and deployments using GHCR.

Setup & Authentication

  • Using GITHUB_TOKEN:
    • Provided automatically in GitHub Actions workflows.
    • Can publish packages associated with the workflow repository.
    • Can install packages if the repository has read access to the package
  • You need to generate a PAT with write:packages, read:packages, and optionally delete:packages and repo scopes.
  • Log in to GHCR using Docker CLI with your PAT.
    export CR_PAT=YOUR_TOKEN
    echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
  • Tag your image using the GHCR naming convention before pushing.
  • Push the image to GHCR using docker push.
    docker push ghcr.io/NAMESPACE/IMAGE_NAME:latest
  • Pull images from GHCR using docker pull.
    docker pull ghcr.io/NAMESPACE/IMAGE_NAME

Naming Convention

  • The format for images is:
    ghcr.io/NAMESPACE/IMAGE_NAME[:TAG].
    • The NAMESPACE is your GitHub username or organization.
    • The <IMAGE_NAME> is the name of your container image.
    • The <TAG> is the version or label, such as latest or v1.0.

Permissions & Security

  • Repository-linked permissions automatically inherit access from the repo.
  • You can define granular permissions for specific users or teams.
  • Anonymous access is allowed for public images.
  • Scoped tokens should follow the principle of least privilege.

Common Use Cases

  • Teams use GHCR to host private container images for internal projects.
  • Open-source developers distribute public images alongside their code.
  • CI/CD pipelines use GHCR with GitHub Actions for automated workflows.
  • Multi-cloud deployments can centralize image hosting in GitHub.

GHCR vs Docker Hub

Feature

GitHub Container Registry (GHCR)

Docker Hub

Integration

Native integration with GitHub ecosystem (repos, Actions, permissions)

Standalone registry, separate from GitHub

Access Control

Repository-linked permissions and granular package-level controls

Namespace-based access control

Authentication

GITHUB_TOKEN (workflows) or GitHub Personal Access Token (classic) with package scopes

Docker Hub access tokens (PATs) or GITHUB_TOKEN passed as a secret in GitHub Actions workflows

Public Images

Anonymous pulls supported for public images

Anonymous pulls supported for public images

Automation

Seamless GitHub Actions workflows for CI/CD

Automated builds and webhooks available

Visibility

Images tied to GitHub repos and organizations

Images tied to Docker Hub namespaces

Security

Scoped PATs and GITHUB_TOKEN with least privilege principle

Docker Hub tokens and account-level permissions; GITHUB_TOKEN usable in GitHub Actions

GitHub Container Registry Cheat Sheet Resources:

https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
https://docs.github.com/en/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container
https://github.blog/news-insights/product-news/introducing-github-container-registry/

▶️ Video Course Sale – Get Video Courses as LOW as $6.99 USD each only!

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

$2.99 AWS and Azure Exam Study Guide eBooks

tutorials dojo study guide eBook

New AWS Generative AI Developer Professional Course AIP-C01

AIP-C01 Exam Guide AIP-C01 examtopics AWS Certified Generative AI Developer Professional Exam Domains AIP-C01

Learn GCP By Doing! Try Our GCP PlayCloud

Learn Azure with our Azure PlayCloud

FREE AI and AWS Digital Courses

FREE AWS, Azure, GCP Practice Test Samplers

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

Follow Us On Linkedin

Written by: Nestor Mayagma Jr.

Nestor is a cloud engineer and content creator at Tutorials Dojo. He's been an active AWS Community Builder since 2022, with a growing interest in multi-cloud technologies across AWS, Azure, and Google Cloud. In his leisure time, he indulges in playing FPS games.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?