问题
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>
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]
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.
回答1:
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>
来源:https://stackoverflow.com/questions/64849028/maven-spring-boot-cannot-push-docker-image