Sunday, September 15, 2024

What is GHCR ( Docker hub container registry

Here are some key benefits of using ghcr.io:

Integration with GitHub: Seamless integration with your existing GitHub workflow.   

Security: Leverages the same security measures as your GitHub repositories.

Version control: Track changes and revert to previous versions of your container images.

Collaboration: Share container images with team members within your organization.

Global content delivery network (CDN): Fast downloads for your container images.

Using ghcr.io is simple:

Push your Docker image to the appropriate namespace within your GitHub account. The format is ghcr.io/<username>/<repository>:<tag>.

Use the image in your applications or deployments by referencing the same format.

Overall, ghcr.io provides a convenient and secure way for developers to manage their Docker container images alongside their code on GitHub. 1  

You can store and manage Docker and OCI images in the Container registry, which uses the package namespace https://ghcr.io.

The Container registry stores container images within your organization or personal account, and allows you to associate an image with a repository. You can choose whether to inherit permissions from a repository, or set granular permissions independently of a repository. You can also access public container images anonymously

GitHub Packages only supports authentication using a personal access token (classic)

To authenticate to a GitHub Packages registry within a GitHub Actions workflow, you can use:

GITHUB_TOKEN to publish packages associated with the workflow repository.

a personal access token (classic) with at least read:packages scope to install packages associated with other private repositories (which GITHUB_TOKEN can't access).

This registry supports granular permissions. For registries that support granular permissions, if your GitHub Actions workflow is using a personal access token to authenticate to a registry, we highly recommend you update your workflow to use the GITHUB_TOKEN

Using the CLI for your container type, sign in to the Container registry service at ghcr.io.

$ echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin

> Login Succeeded

Pushing container images

docker push ghcr.io/NAMESPACE/IMAGE_NAME:latest

Replace NAMESPACE with the name of the personal account or organization to which you want the image to be scoped.

This example pushes the 2.5 version of the image.

docker push ghcr.io/NAMESPACE/IMAGE_NAME:2.5

references:

https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#about-the-container-registry

No comments:

Post a Comment