我想要一个services
具有私有(private)注册表的 Github Actions 工作流程文件部分。简化的配置如下所示:
jobs:
my_job:
runs-on: ubuntu-latest
services:
image-name:
image: docker.pkg.github.com/<org>/<repo>/<image>
steps:
# ...
如果重要的话,存储库位于同一组织内。也可以在本地使用适当的凭据提取图像,但显然在 github 操作管道中失败并出现错误:
Error response from daemon: Get <image_url>: no basic auth credentials
所以我的问题是:是否可以通过环境变量(在 Github 中又名 Secrets)或 services.options
的一些标志来指定凭据?存在?我相信this可以替代手动登录/拉取/启动,但我更喜欢声明方式。
最佳答案
自 2020 年 9 月 24 日起,是的,应该可以为私有(private)注册表指定您的凭据。
参见“GitHub Actions: Private registry support for job and service containers”
You can now use images from private registeries in job and service containers.
Here's an example of using private images from Docker Hub:
jobs:
build:
container:
image: octocat/ci-image:latest
credentials:
username: mona
password: ${{ secrets.docker_hub_password}}
services:
db:
image: octocat/testdb:latest
credentials:
username: mona
password: ${{ secrets.docker_hub_password }}
关于docker - 如何在 Github Action 上登录 pull registry for services,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62608259/