当试图释放Docker映像到GHCR时,Buildx授权错误



我得到这个错误:

error: failed to solve: error writing layer blob: server message: insufficient_scope: authorization failed

在GitHub Action完成构建Docker镜像后:

# https://docs.docker.com/ci-cd/github-actions/
name: Publish Docker Image
on:
workflow_dispatch:
push:
branches:
- master
paths:
- "Dockerfile"
schedule:
- cron: "0 6 * * */3"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ghcr.io/t145/black-mirror:latest
cache-from: type=registry,ref=t145/black-mirror:buildcache
cache-to: type=registry,ref=t145/black-mirror:buildcache,mode=max

按照文档顶部链接的指南进行配置。为什么会出现这个错误?

尝试更新cache-fromcache-to缓存引用到ghcr.io/t145/black-mirror。当你省略注册表(ghcr.io)时,我相信它默认为DockerHub。

最新更新