This page looks best with JavaScript enabled

Finally Here - GitHub Container Registry (ghcr.io)

 ·  β˜• 3 min read

1. Github Container Registry

On September 1, GitHub announced that Github Container Registry had entered public beta, offering a free, unlimited-capacity Docker image registry service during the testing period.

No more worrying about docker.io wiping images out of the blue. How nice, how sweet!

GitHub is using hosted code repositories as its entry point and gradually covering the entire R&D toolchain to build a one-stop DevOps platform. Project management has Issues and Projects, package management has Packages, CI has Actions, knowledge management has Wiki β€” the coverage keeps widening.

Next up should be the CD part. Offering a container hosting service would be a good choice. @GitHub

2. Pushing Your First Image

Let’s try pushing an image now.

2.1 Creating a Login Token

Pushing an image directly with your GitHub username and password gives an error:

1
unauthorized: Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:packages'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.

Github Container registry requires a token created on the https://github.com/settings/tokens/new page to be used as the password before you can push images.

Open the link above, check write:packages and read:packages, and repo will be selected automatically. Create the token.

Below, XXX is used to refer to the token value here.

2.2 Pushing the Image

  • Log in
1
2
3
4
5
echo "XXX" | docker login ghcr.io -u shaowenchen --password-stdin

WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
  • Create a Tag

List the images

1
2
3
docker images

mysql     8.0.11      5dbe5b6313e1        2 years ago         445MB

Create a tag

1
docker tag 5dbe5b6313e1 ghcr.io/shaowenchen/mysql
  • Push
1
2
3
4
5
docker push ghcr.io/shaowenchen/mysql

The push refers to repository [ghcr.io/shaowenchen/mysql]
ae2d2cded00e: ...
latest: digest: sha256:d98a807f255bd60cd7807af6a11f94cd2456a2908a12adb3737088473c1625a2 size: 2828

That completes the image push. But the image is not pullable by everyone. Let’s look at image visibility management next.

2.3 Visibility Management

After the image is pushed, you can see the image list under the packages tab on your personal homepage.

Images are pushed as Private by default, and only authorized accounts can pull them. Public images, by contrast, can be pulled anonymously with no restrictions.

  • Private

On the Packages settings page of a Private image, you can change the Private image to Public, and you can also manage authorization via Manage Access.

  • Public

Note that on the Packages settings page of a Public image, you cannot change the image’s visibility β€” you can only delete the image.

3. Differences from docker.pkg.github.com

ghcr.io is similar to docker.pkg.github.com: both provide an image registry service and use the same authentication method. But there are some differences:

  • Different dimension

ghcr.io targets the account dimension β€” it is a service provided with the account as the basic object. docker.pkg.github.com, on the other hand, targets the repository dimension β€” it is a service provided with the repository as the basic object.

  • Different management granularity

Images in docker.pkg.github.com cannot be deleted directly; you can only delete them indirectly by deleting the repository.

In ghcr.io, by contrast, images can be fully managed directly.

  • Different image format

Compare the image formats of the two:

1
docker.pkg.github.com/OWNER/REPOSITORY/IMAGE-NAME
1
ghcr.io/OWNER/IMAGE-NAME

The docker.pkg.github.com image format looks like docker.pkg.github.com/shaowenchen/pipeline-test/mysql, carrying the repository name in the name. The ghcr.io/shaowenchen/mysql provided by ghcr.io, by contrast, is more consistent with the naming conventions of other image registries.

4. References


WeChat Official Account
WRITTEN BY
WeChat Official Account