Maven Spring Boot Cannot Push Docker Image

喜你入骨 提交于 2021-01-28 14:38:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!