Pushing to GitHub Container Registry: unauthorized: unauthenticated: User cannot be authenticated with the token provided

huangapple go评论114阅读模式
英文:

Pushing to GitHub Container Registry: unauthorized: unauthenticated: User cannot be authenticated with the token provided

问题

当我尝试:

docker push ghcr.io/username/imagename:latest


根据[GitHub文档](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry),我看到

未经授权:未认证:无法使用提供的令牌对用户进行认证。


如何将镜像推送到ghcr?
英文:

When I try:

docker push ghcr.io/username/imagename:latest 

as per GitHub docs, I see

unauthorised: unauthenticated: User cannot be authenticated with the token provided.

How do I push the image to ghcr?

答案1

得分: 3

你需要授予 Docker 权限以推送到你的 GHCR(GitHub 官方文档中提供了具体说明,但可能有点难以找到)。

3个步骤:

  1. 创建一个访问令牌(PAT)(这里),并给予它读/写 packages权限。

  2. 复制 PAT 到剪贴板,并在你的终端中运行以下命令:

docker login ghcr.io -u 用户名 -p ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

用户名替换为你的 GitHub 用户名,ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 替换为刚刚创建的 PAT。现在 Docker 可以访问你的 GHCR,包括推送的权限。

  1. 再次尝试你的push命令:
docker push ghcr.io/用户名/镜像名称:latest
英文:

You have to give docker permission to push to your GHCR (instructions are in the github docs, but are somewhat buried).

3 Steps:

  1. Create an access token (PAT) (here) and give it read/write packages permissions.

  2. Copy the PAT to clipboard, and run this in your terminal:

docker login ghcr.io -u username -p ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

replacing username with your GitHub username, and ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with the PAT you just made. Now docker has access to your GHCR, including the ability to push.

  1. Try your push command again and it will work:
docker push ghcr.io/username/imagename:latest 

huangapple
  • 本文由 发表于 2023年4月4日 08:12:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75924590.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定