使用 GHCR 映像时,Docker 登录在 GitHub Actions 工作流程中间歇性失败

问题描述 投票:0回答:1

我正在尝试在容器中运行 GitHub Actions 工作流程,如下所示。

name: My Workflow
on:
  push:
    branches: [ main ]
jobs:
  container-test-job:
    runs-on: [selfhosted]
    container:
      image: ghcr.io/myorg/myrepo/node:18
    steps:
      - name: Echo
        run: echo "Hello"

在“初始化容器”步骤中,它正在尝试登录 GHCR,我相信它正在后端使用 GITHUB_TOKEN 进行身份验证。但登录失败并出现以下错误,并且它是间歇性发生的,我无法按需重现它。

Docker login for 'ghcr.io' failed with exit code 1

我厌倦了检查守护程序日志,并在日志中发现了以下错误。

level=info msg="Error logging in to endpoint, trying next endpoint" error="Get \https://ghcr.io/v2/\: remote error: tls: internal error"

level=error msg="Handler for POST /v1.41/auth returned error: Get \https://ghcr.io/v2/\: remote error: tls: internal error"

这些错误是什么意思?我该如何解决这个问题?

docker github github-actions docker-registry ghcr
1个回答
0
投票

您可以定义容器注册表的凭据,例如:

container:
  image: ghcr.io/myorg/myrepo/node:18
  credentials:
     username: ${{ github.actor }}
     password: ${{ secrets.github_token }}

这些凭据与您向

docker login
命令提供的凭据相同。

© www.soinside.com 2019 - 2024. All rights reserved.