Github操作:构建和推送Docker映像失败。服务器消息:不足_作用域:授权失败

时间:2020-10-05 20:09:46

标签: spring-boot docker github-actions docker-push

我正在使用GitHub上的GitHub操作“ Build and push Docker images”,它是经过验证的评分最高的操作。

我的YAML文件的相关代码段如下

  - name: Set up QEMU
    uses: docker/setup-qemu-action@v1
  - name: Set up Docker Buildx
    uses: docker/setup-buildx-action@v1
  - name: Login to DockerHub
    uses: docker/login-action@v1
    with:
      username: ${{ secrets.DOCKERHUB_USERNAME }}
      password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
  - name: Build and push
    id: docker_build
    uses: docker/build-push-action@v2
    with:
      push: true
      tags: user/app:latest
  - name: Image digest
    run: echo ${{ steps.docker_build.outputs.digest }}

Just as it was shown in the example。当工作流程运行时,我始终看到错误

10 [stage-1 2/2] COPY --from=build /workspace/target/*.jar app.jar
#10 DONE 0.9s

#12 exporting to image
#12 exporting layers
#12 exporting layers 4.3s done
#12 exporting manifest sha256:dafb0869387b325491aed0cdc10c2d0206aca28006b300554f48e4c389fc3bf1 done
#12 exporting config sha256:f64316c3b529b43a6cfcc933656c77e556fea8e5600b6d0cce8dc09f775cf107 done
#12 pushing layers
#12 pushing layers 0.8s done
#12 ERROR: server message: insufficient_scope: authorization failed
------
 > exporting to image:
------
failed to solve: rpc error: code = Unknown desc = server message: insufficient_scope: authorization failed
Error: The process '/usr/bin/docker' failed with exit code 1

我的标准Spring Boot应用程序的Dockerfile的内容如下所示

FROM maven:3.6.3-jdk-11-slim AS build
RUN mkdir -p /workspace
WORKDIR /workspace
COPY pom.xml /workspace
COPY src /workspace/src
RUN mvn -B -f pom.xml clean package -DskipTests

FROM openjdk:11-jdk-slim
COPY --from=build /workspace/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","app.jar"]

任何线索如何解决?

当使用如下所示的GitHub动作时,我能够发布到docker-hub

  - name: Build and push docker image
    uses: elgohr/Publish-Docker-Github-Action@master
    with:
      name: bloque/sales-lead-management
      username: ${{ secrets.DOCKERHUB_USERNAME }}
      password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

0 个答案:

没有答案