today I used the command mvn spring-boot:build-image to build a docker image. but it failed the error message:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.RELEASE:build-image (default-cli) on project hotel-common: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.RELEASE:build-image failed: Docker API call to 'localhost/v1.24/images/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase-platform-api-0.3' failed with status code 500 "Internal Server Error" -> [Help 1]
then I checked the docker API version:
echo -e "GET /info HTTP/1.0\r\n" | sudo nc -U /var/run/docker.sock
HTTP/1.0 200 OK
Api-Version: 1.39
Content-Type: application/json
Docker-Experimental: false
Ostype: linux
Server: Docker/18.09.0 (linux)
Date: Wed, 20 May 2020 07:38:48 GMT
Comment From: wilkinsona
The 500 error indicates that a failure has occurred in Docker. Its logs should provide some more information about why it has failed. Can you please share those logs with us?
Comment From: lixinchuang
I read the relative springboot sourcecode,found that,API_VERSION was hardcoded to "1.24",but the docker ‘s api version is 1.39... is this the root cause?
Comment From: bclozel
@lixinchuang did you see this comment: https://github.com/spring-projects/spring-boot/issues/19945#issuecomment-631311104
Comment From: lltx
environment
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:24:18 2019
OS/Arch: linux/amd64
Experimental: false
exec spring-boot:build-image
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.RELEASE:build-image (default-cli) on project demo-layer: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.RELEASE:build-image failed: Docker API call to '172.17.0.111:2375/v1.24/images/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase-platform-api-0.3' failed with status code 500 "Internal Server Error" -> [Help 1]
docker remote api log
5月 22 14:08:24 111-jenkins dockerd[1079]: time="2020-05-22T14:08:24.979226960+08:00" level=error msg="Handler for POST /v1.24/images/create returned error: Get https://gcr.io/v2/: dial tcp 7
- It seems to be related to the network
Comment From: lixinchuang
@lixinchuang did you see this comment: #19945 (comment)
yes,but that issue was closed,so i opened this new issue
Comment From: nkjackzhang
I read the relative springboot sourcecode,found that,API_VERSION was hardcoded to "1.24",but the docker ‘s api version is 1.39... is this the root cause?
Don't try to find reason by yourself, just show the error log of docker.
Comment From: xJoeWoo
If you're in China, gcr.io
is blocked because it's a service of Google. :(
Http POST:
localhost:2375/v1.24/images/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase-platform-api-0.3
Reponse:
{
"message": "Get https://gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
}
Gradle error:
Execution failed for task ':xxx:bootBuildImage'.
> Docker API call to 'localhost/v1.24/images/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase-platform-api-0.3' failed with status code 500 "Internal Server Error"
And there's no mirror registries remain available currently in China. :(
I hope paketo
can also deploy their images to Docker Hub which is not blocked and lots of mirrors are available.
Comment From: wilkinsona
Thanks, @xJoeWoo. We should improve our error message here. The message in body of the 500 response is useful as it gives a hint as to why the failure occurred.
Comment From: CoderPraBhu
I saw similar error when wrong value was used in builder property of Gradle bootBuildImage task. I wanted to use imageName but used wrongly used builder property. Able to build image after correction.
Docker API call to 'localhost/v1.24/images/create?fromImage=gcr.io%2Fprojectid%2Fprojectname%3Alatest' failed with status code 500 "Internal Server Error"
Caused by: org.springframework.boot.buildpack.platform.docker.transport.DockerEngineException: Docker API call to 'localhost/v1.24/images/create?fromImage=gcr.io%2Fprojectid%2Fprojectname%3Alatest' failed with status code 500 "Internal Server Error"
at org.springframework.boot.buildpack.platform.docker.transport.HttpClientTransport.execute(HttpClientTransport.java:135)
bootBuildImage {
// builder = "gcr.io/projectid/appname" // this caused 500 error
imageName = "gcr.io/projectid/appname"
}
I was referring to following sample of topical guide:
You can modify the image name in Maven using
code sample for maven here
and in Gradle using:
bootBuildImage {
builder = "myorg/demo"
}
I had just opened https://github.com/spring-guides/top-spring-boot-docker/issues/9 in repository for the topical guide but closed after noticing the PR https://github.com/spring-guides/top-spring-boot-docker/pull/8, which is yet to be merged.