Neil Kuan
September 26, 2020

Introducing GitHub Container Registry !!!

Posted on September 26, 2020  •  2 minutes  • 239 words

Github Container Registry

source new : https://github.blog/2020-09-01-introducing-github-container-registry/

自去年發布GitHub Packages以來,已經從GitHub下載了數億個軟件包,其中Docker是Packages中僅次於npm的第二受歡迎的ecosystem,儘管GitHub Packages已經為團隊提供了更大的軟件供應鏈可追溯性,但如今,GitHub 正在添加新功能,以改善它通過GitHub Container Registry為開發人員提供的體驗和性能。

Introducing GitHub Container Registry

GitHub Container Registry現已作為公共Beta發布,它改進了我們在GitHub Packages中處理容器的方式。通過今天引入的新功能,您可以更好地實施訪問策略,鼓勵使用標準 base image,並通過在整個 organization 中更輕鬆地共享來促進內部使用。並且提供了開源專案可以拜放 container 的地方for free .

廢話結束 ,那麼要怎麼做才能 在 Github Container Registry 上面擺放 Public image 給予他人來下載勒

  1. 首先準備 github access token (以下為需要的權限)
    • Select the read:packages scope to download container images and read their metadata.
    • Select the write:packages scope to download and upload container images and read and write their metadata.
    • Select the delete:packages scope to delete container images.

順序流程為 : settings → Developer Settings → Personal access tokens → Generate new token

settings → Developer Settings → Personal access tokens → Generate new token

settings → ****Developer Settings ****→ Personal access tokens → Generate new token

settings → Developer Settings → Personal access tokens → Generate new token

settings → Developer Settings → Personal access tokens → Generate new token → copy it !!!

  1. docker host
# 剛剛 copy 的 personal access tokens
export CR_PAT="xxxxxxxxxxxxxxxxxxxxxxxx"
export USERNAME="REPLACE_YOUR_GITHUB_USERNAME"

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

# 使用一個簡單的範例 從 docker hub 拉取 alpine:latese 
docker pull alpine:latest

# 打上 github container registry tag
docker tag alpine:latest ghcr.io/$USERNAME/test-ghcr:test

# push to github container registry
docker push ghcr.io/$USERNAME/test-ghcr:test
  1. public container image

接下來你可以到你 github 的 個人頁面 的 Packages ,可以發現目前是 private 的 所以我們必須讓它公有化,這樣在拉取image 不需要有權限。

你就可以在任何地方透過docker pull ghcr.io/$USERNAME/test-ghcr:testGithub Container Registry 拉取你的 image 來用拉!!!

see more : https://docs.github.com/en/free-pro-team@latest/packages/getting-started-with-github-container-registry

大功告成 下次來講

有關於 github action 搭配 github container registry

2020年9月26日 Neil Kuan

Follow me

Here's where I hang out in social media