我有两个存储库。A和B。
在 A 里面,我有一个 docker 镜像。假设它的名字是ghcr.io/org/a
在 B 内部,我有一个想要使用这个包的操作。两个存储库都是私有的。
这是我的操作代码:
- name: Log in to GitHub Container Repository
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull the image
run: |
docker pull ghcr.io/org/a:latest
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我首先登录 ghcr.io 并收到消息Login succeeded。然后我想从我的其他存储库中提取图像。
但我收到这个错误:
来自守护程序的错误响应:被拒绝
但是,当我从自己的计算机登录 ghcr.io 时,我可以访问这两个存储库,并且可以从我的任何私有存储库中提取任何图像。
为什么B的GitHub Action登录后无法从A拉取镜像?
我遇到了同样的问题,但以下内容对我有用:
首先,正如 @SalTorre 所建议的,我需要org/b通过以下接口明确访问该包:
https://github.com/orgs/org/packages/container/a/settings
Run Code Online (Sandbox Code Playgroud)
接下来,在图像存储库中(org/a在您的情况下),我需要专门向需要在 GHA 中启动使用图像的工作流程的每个用户(或包含所述用户的一组团队)授予权限。这是因为身份验证使用 的凭据${{ github.actor }},这是启动工作流程的特定 GitHub Actions 用户。
执行此操作的 URL 在这里:
https://github.com/org/a/settings/access
Run Code Online (Sandbox Code Playgroud)
设置这两个权限后,我的工作流程就可以使用我的定制容器。
即使我将存储库 a 中的包的读取权限授予存储库 b,我也遇到同样的错误。
Starting xxx service container
/usr/bin/docker --config /home/runner/work/_temp/.docker_4a0e5f4d-beda-48eb-9580-eb88fec51e3d login ghcr.io -u user --password-stdin
/usr/bin/docker --config /home/runner/work/_temp/.docker_4a0e5f4d-beda-48eb-9580-eb88fec51e3d pull ghcr.io/onstructive/xxx/xxx:0.1.9-native
Error response from daemon: denied
Warning: Docker pull failed with exit code 1, back off 9.427 seconds before retry.
Run Code Online (Sandbox Code Playgroud)
然后我发现我在存储库 b 中的工作流程尝试从存储库 a 中的包中提取图像,需要声明其权限。
Starting xxx service container
/usr/bin/docker --config /home/runner/work/_temp/.docker_4a0e5f4d-beda-48eb-9580-eb88fec51e3d login ghcr.io -u user --password-stdin
/usr/bin/docker --config /home/runner/work/_temp/.docker_4a0e5f4d-beda-48eb-9580-eb88fec51e3d pull ghcr.io/onstructive/xxx/xxx:0.1.9-native
Error response from daemon: denied
Warning: Docker pull failed with exit code 1, back off 9.427 seconds before retry.
Run Code Online (Sandbox Code Playgroud)
小智 3
您是否授予存储库 B 对该包的显式访问权限?
https://github.com/orgs/<ORG_NAME>/packages/container/<PACKAGE_NAME>/settings
| 归档时间: |
|
| 查看次数: |
7544 次 |
| 最近记录: |