Running mvn spring-boot:build-image
and getting this error:
...
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.M4:build-image (default-cli) on project
demo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.M4:build-image failed: Docker API c
all to '/var/run/docker/docker.sock/v1.24/images/create?fromImage=docker.io%2Fcloudfoundry%2Fcnb%3Abionic-platform-api-0.2' fai
led with status code 500 "/var/run/docker/docker.sock: Name or service not known" -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
The Docker CLI works fine via a DOCKER_HOST
env var (probably a plausible analog of a "standard" low-trust enterprise environment). I assume that this is messing with the Maven plugin.
Comment From: dsyer
This was in eduk8s BTW, and the workshop died before I had a chance to get more details. It's a restrictive environment but probably not unrealistic in the wild.
Comment From: philwebb
20538 was fixed in M4 so there must be something we missed.
Comment From: dsyer
That does look like a similar issue. In this case DOCKER_HOST was set to a socket (ie a file) so maybe that’s the corner case we didn’t cover yet?
Comment From: jorgemoralespou
We can confirm this is still happening and as @dsyer mentions we think that it's a problem when Docker socket is not treated like a linux socket but rather as an http endpoint. We can see a stacktrace like this:
rg.springframework.boot:spring-boot-maven-plugin:2.3.0.BUILD-SNAPSHOT:build-image (default-cli) on project demo:
Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.BUILD-SNAPSHOT:build-image failed: Docker API cal
l to '/var/run/docker/docker.sock/v1.24/images/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase-platform-api-0.3' failed wit
h status code 500 "/var/run/docker/docker.sock: Name or service not known"
This trace makes us think that connection to a socket is not being made properly.
Comment From: dsyer
Here's the detail from the stack trace:
Caused by: org.springframework.boot.buildpack.platform.docker.transport.DockerEngineException: Docker API call to '/var/run/doc
ker/docker.sock/v1.24/images/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase-platform-api-0.3' failed with status
code 500 "/var/run/docker/docker.sock: Name or service not known"
at org.springframework.boot.buildpack.platform.docker.transport.HttpClientTransport.execute (HttpClientTransport.java:140)
at org.springframework.boot.buildpack.platform.docker.transport.HttpClientTransport.post (HttpClientTransport.java:82)
at org.springframework.boot.buildpack.platform.docker.DockerApi$ImageApi.pull (DockerApi.java:155)
at org.springframework.boot.buildpack.platform.build.Builder.pullBuilder (Builder.java:84)
at org.springframework.boot.buildpack.platform.build.Builder.build (Builder.java:62)
at org.springframework.boot.maven.BuildImageMojo.buildImage (BuildImageMojo.java:136)
at org.springframework.boot.maven.BuildImageMojo.execute (BuildImageMojo.java:128)
...
I can confirm that the socket works with curl:
$ curl --unix-socket /var/run/docker/docker.sock http://localhost/images/json | jq
[
{
"Containers": -1,
"Created": 1588752403,
"Id": "sha256:0f3310167bdc7dd1f27409b870b82c61f200ddac4c44aea5f456b024cc295b5d",
"Labels": null,
"ParentId": "",
"RepoDigests": [
"dsyer/demo@sha256:6477cd3f8bf2f17faafb0babef5e24b565ab6fa6cdd35e52011beec55dafd6ca",
"lab-spring-boot-w01-s001-registry.training.failk8s.dev/springguides/demo@sha256:6477cd3f8bf2f17faafb0babef5e24b565ab6fa6
cdd35e52011beec55dafd6ca"
],
"RepoTags": [
"dsyer/demo:latest",
"lab-spring-boot-w01-s001-registry.training.failk8s.dev/springguides/demo:latest"
],
"SharedSize": -1,
"Size": 123002083,
"VirtualSize": 123002083
}
]
Comment From: scottfrederick
Docker socket is not treated like a linux socket but rather as an http endpoint.
Currently, when the DOCKER_HOST
environment variable is set Spring Boot assumes that it is an HTTP endpoint. If DOCKER_HOST
is not set then Boot uses a domain socket on Linux. We'll need to update this logic to handle this case where DOCKER_HOST
is a domain socket.