Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better diagnostics when building an OCI image fails due to a 500 response from Docker #21515

Closed
lixinchuang opened this issue May 20, 2020 · 9 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@lixinchuang
Copy link

lixinchuang commented May 20, 2020

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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 20, 2020
@wilkinsona
Copy link
Member

wilkinsona commented May 20, 2020

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?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label May 20, 2020
@lixinchuang
Copy link
Author

lixinchuang commented May 21, 2020

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?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 21, 2020
@bclozel
Copy link
Member

bclozel commented May 21, 2020

@lixinchuang did you see this comment: #19945 (comment)

@lltx
Copy link
Contributor

lltx commented May 22, 2020

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

@lixinchuang
Copy link
Author

@lixinchuang did you see this comment: #19945 (comment)

yes,but that issue was closed,so i opened this new issue

@nkjackzhang
Copy link
Contributor

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.

@xJoeWoo
Copy link
Contributor

xJoeWoo commented May 25, 2020

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.

@wilkinsona
Copy link
Member

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.

@wilkinsona wilkinsona changed the title spring-boot:build-image does not work Provide better diagnostics when building an OCI image fails due to a 500 response from Docker May 26, 2020
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels May 26, 2020
@wilkinsona wilkinsona added this to the 2.3.x milestone May 26, 2020
@scottfrederick scottfrederick self-assigned this May 27, 2020
@CoderPraBhu
Copy link

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 spring-guides/top-spring-boot-docker#9 in repository for the topical guide but closed after noticing the PR spring-guides/top-spring-boot-docker#8, which is yet to be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

9 participants