GitHub Container Registry: BETTER than Docker Hub? (2024)

Davide 'CoderDave' Benvegnù for GitHub

Posted on

GitHub Container Registry: BETTER than Docker Hub? (4) GitHub Container Registry: BETTER than Docker Hub? (5) GitHub Container Registry: BETTER than Docker Hub? (6) GitHub Container Registry: BETTER than Docker Hub? (7) GitHub Container Registry: BETTER than Docker Hub? (8)

#github #devops #containers #docker

GitHub Container Registry improves how we handle containers within GitHub. Let's see what it is, how it works, and if it is better than Docker Hub.

Video

As usual, if you are a visual learner, or simply prefer to watch and listen instead of reading, here you have the video with the whole explanation and demo, which to be fair is much more complete than this post.

Link to the video: https://youtu.be/WjzA9dfk5w4

If you rather prefer reading, well... let's just continue :)

GitHub Container Registry?

The GitHub Container Registry (GHCR) is a redesigned, enhanced version of GitHub Packages. It not only replaces the Packages Docker service, but also it represents a fundamental shift in how GitHub will provide packages to its customers, because Packages are now tied to organizations and accounts instead of repos.

And in the case of the Container Registry, it also has its own URL: ghcr.io.

GHCR also represents a step toward a Cloud Native approach to CI/CD workflows. This service is in fact built from the latest docker distribution and offers OCI compatible storage.

How To Push an Image?

Pushing a container image to the GitHub Container Registry is super easy and straight forward.

You just authenticate using your GitHub Username and a PAT with the write packages scope (watch this video to see how to create a PAT in GitHub), for example with Docker Login, and push the container as you would normally do.

You just have to tag the image with the format ghcr.io/OWNER/IMAGE_NAME:version, where OWNER is the name of your user or the organization.

And if you are doing it in GitHub Actions it's even easier.

- name: Log into GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin- name: Push image to GitHub Container Registry run: | IMAGE_ID=ghcr.io/${{ github.repository_owner }}/MyBeautifulContainer:123  docker push $IMAGE_ID

You can in fact use the GITHUB_TOKEN environment variable instead of your PAT, github.actor to automatically retrieve the current user running the workflow, and github.repository_owner to automatically get the user or organization this container belongs to.

Better than Docker Hub?

Is it better than Docker Hub? You tell me.

You can link GHCR to a repo, so you can get the Readme directly as description for that image.

And you also have granular control of the permissions. You can restrict the usage of the container image only to some of your repos or your organization's repos, and you can also manage the permissions for individual users or teams.

Finally, you can change the visibility of the container image between private and public.

So yes, for me it is better than Docker Hub. Adn the fact that it is already directly into GitHub makes it even easier to use.

Final Considerations

Note that the Container registry is currently in public beta and may be subject to changes. It is free for public images, while for private images Container Registry is free during the beta, and as part of GitHub Packages will follow the same pricing model when generally available.

Also, remember that to use the Container registry, you must enable the feature preview. Just go to your profile settings and access the Feature Preview submenu.

Conclusions

What do you think of the GitHub Container Registry? Are you using it?
Let me know in the comment section below.

Like, share and follow me 🚀 for more content:

📽 YouTube
Buy me a coffee
💖 Patreon
🌐 CoderDave.io Website
👕 Merch
👦🏻 Facebook page
🐱‍💻 GitHub
👲🏻 Twitter
👴🏻 LinkedIn
🔉 Podcast

GitHub Container Registry: BETTER than Docker Hub? (9)

1

Top comments (11)

Subscribe

Logan Lindquist

Logan Lindquist

I dream of a world that is fair and equitable in its society and has a sustainable impact to our environment.

  • Location

    Austin, TX

  • Work

    Engineerer at Legacy Beta Inc

  • Joined

Jun 14 '21

  • Copy link

Having it in Gitlab has been nice. Will be great when Github has feature parity on this.

Davide 'CoderDave' Benvegnù

Davide 'CoderDave' Benvegnù

DevOps Lead 👨‍💻 • YouTuber @ CoderDave 🎥 • Ex MMA fighter 🥊

  • Location

    Hong Kong

  • Work

    DevOps and Infra Lead @ PlayStudios

  • Joined

Jun 14 '21

  • Copy link

Not sure what you mean since this is in GitHub 😅

Logan Lindquist

Logan Lindquist

I dream of a world that is fair and equitable in its society and has a sustainable impact to our environment.

  • Location

    Austin, TX

  • Work

    Engineerer at Legacy Beta Inc

  • Joined

Jun 15 '21

  • Copy link

Gitlab has had it for a while, several years, and I am just saying it is nice that Github is catching up.

Davide 'CoderDave' Benvegnù

Davide 'CoderDave' Benvegnù

DevOps Lead 👨‍💻 • YouTuber @ CoderDave 🎥 • Ex MMA fighter 🥊

  • Location

    Hong Kong

  • Work

    DevOps and Infra Lead @ PlayStudios

  • Joined

Jun 15 '21

  • Copy link

Ah ok, got it. Well, GitHub had it already but was, as GitHub Pacjages, limited to a single repo (even tho it could be used more widely thanks to some workaround)

Jonas Brømsø

Jonas Brømsø

Computer programmer, runner, LEGO builder, powernapper, yakshaver and father of 2 boys all squeezed in the few hours available.

  • Location

    Copenhagen, Denmark

  • Work

    Product Manager at DomuTech A/S

  • Joined

Jun 14 '21

  • Copy link

I have been pondering on how to use GHCR instead of DockerHub for GitHub actions, but have not had the time to investigate on how to do the switch. A switch I think will be fairly trivial - any pointers/suggestions most welcome.

Forrest

Forrest

  • Joined

Oct 19 '21

  • Copy link

Can anyone tell me if these images load faster in github actions?

Davide 'CoderDave' Benvegnù

Davide 'CoderDave' Benvegnù

DevOps Lead 👨‍💻 • YouTuber @ CoderDave 🎥 • Ex MMA fighter 🥊

  • Location

    Hong Kong

  • Work

    DevOps and Infra Lead @ PlayStudios

  • Joined

Oct 20 '21

  • Copy link

it should be slightly faster because they are hosted on the same infrastructure

Tomas Balaz

Tomas Balaz

  • Joined

Nov 11 '21

  • Copy link

hi guys
do you know how to allow visibility of organisation images for anonymous user? images can be pulled anonymously but link to image in GHCR returns 404 if user is not logged in

Irving Caamal

Irving Caamal

Full-Stack Developer, Javascripter, passionate for new technologies and best practices.

  • Email

    irvv.17@gmail.com

  • Location

    Cancun, Quintana Roo

  • Education

    Computer Systems Engineer

  • Pronouns

    He/Him/His

  • Work

    Software Engineer

  • Joined

Jun 15 '21 • Edited on Jun 15 • Edited

  • Copy link

I've created a basic example of node/express app deployed into Azure using GitHub container registry here github.com/irvv17/deployment-nodea... . Great Tool.

૮༼⚆︿⚆༽つ

૮༼⚆︿⚆༽つ

Self-taught from hobby. Open for collaboration.

  • Location

    Kepler-22b

  • Pronouns

    any gender neutral pronouns except they/them

  • Joined

Jun 10 '21 • Edited on Jun 10 • Edited

  • Copy link

If the project itself is publicly open, it's better to host the image container on IPFS too 😉
github.com/ipdr/ipdr

Davide 'CoderDave' Benvegnù

Davide 'CoderDave' Benvegnù

DevOps Lead 👨‍💻 • YouTuber @ CoderDave 🎥 • Ex MMA fighter 🥊

  • Location

    Hong Kong

  • Work

    DevOps and Infra Lead @ PlayStudios

  • Joined

Jun 11 '21

  • Copy link

Well, images hosted on GHCR can be publicly availbale to anyone :)

But I didn't know IPFS, let me take a look at it

For further actions, you may consider blocking this person and/or reporting abuse

GitHub Container Registry: BETTER than Docker Hub? (2024)

References

Top Articles
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 6638

Rating: 4.7 / 5 (57 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.