Maven Spring Boot无法推送Docker映像 [英] Maven Spring Boot Cannot Push Docker Image
问题描述
使用Spring Boot 2.4.0,我试图配置 spring-boot:build-image
任务以将图像推送到我的私有GitHub容器注册表中.
Using Spring Boot 2.4.0, I'm trying to configure the spring-boot:build-image
task to push an image to my private GitHub container registry.
I used these instructions to configure my POM as follows:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>ghcr.io/abc/${project.artifactId}:${project.version}</name>
<publish>true</publish>
</image>
<docker>
<publishRegistry>
<username>abc</username>
<token>mytoken</token>
<url>https://ghcr.io</url>
</publishRegistry>
</docker>
</configuration>
</plugin>
当我执行 spring-boot:build-image
任务时,它会构建图像,但是在尝试推送时出现以下错误:
When I execute the spring-boot:build-image
task, it builds the image but I get the following error when it tries to push:
[INFO] Successfully built image 'ghcr.io/abc/def:1.5.0'
[INFO]
[INFO] > Pushing image 'ghcr.io/abc/def:1.5.0' 100%
Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.0:build-image failed: Error response received when pushing image: error parsing HTTP 405 response body: unexpected end of JSON input: "" -> [Help 1]
我可以使用 docker push
手动推送图像,并且我尝试执行 docker login
也不起作用.我也没有任何防火墙或代理.
I can manually push the image using docker push
, and I have tried doing a docker login
which doesn't help either. I am also not behind any firewall or proxy.
推荐答案
万一其他人发现了这个问题,问题就出在了maven插件配置中.我使用的是< token>
而不是< password>
.以下是有效的正确XML:
In case anyone else finds this, the problem ended up being a typo in the maven plugin configuration. I was using <token>
instead of <password>
. Below is the correct XML that works:
<docker>
<publishRegistry>
<username>abc</username>
<password>mytoken</password>
<url>https://ghcr.io</url>
</publishRegistry>
</docker>
这篇关于Maven Spring Boot无法推送Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!