Comments (5)
Thanks for the report and all the detail. It's hard to tell what the Docker daemon doesn't like about the call to /v1.24/containers/create
. Can you get more detail from the daemon logs when the error occurs?
One thing that I'm not sure about in your configuration is the <bindings>/var/run/docker.sock:/var/run/docker.sock</bindings>
. Typically that would require a valid path /var/run/docker.sock
in the local environment so that it could bind the same path in the container, but since you're setting <host>tcp://localhost:2375</host>
I assume you can't use /var/run/docker.sock
to talk to the daemon locally. If that binding source path doesn't exist locally that might cause the daemon to throw an error.
If the tcp://
address is also available to containers with dind, you might try setting <bindHostToBuilder>true</bindHostToBuilder>
in the <docker></docker>
section instead. Alternatively, you can set a DOCKER_HOST
environment variable, which will be used by the local Spring Boot plugin code and by the CNB lifecycle code running in the container.
from spring-boot.
Hi @scottfrederick, thanks for your quick reply.
I did many other tests, I'm listing them below. Keep in mind that in all of them the DOCKER_HOST environment property is available:
- name: DOCKER_HOST
value: "tcp://localhost:2375"
Test 1:
1. No <host> tag
2. No <bindings> tag
3. No <bindHostToBuilder> tag
Result:
[INFO] [creator] ERROR: failed to initialize docker client: failed to connect to docker socket: dial unix /var/run/docker.sock: connect: connection refused
[...]
Caused by: org.springframework.boot.buildpack.platform.build.BuilderException: Builder lifecycle 'creator' failed with status code 1
Test 2:
1. No <host> tag
2. No <bindings> tag
3. Added <bindHostToBuilder>true</bindHostToBuilder> tag
Result:
ERROR: failed to initialize analyzer: getting previous image: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
Test 3:
1. No <bindings> tag
2. No <bindHostToBuilder> tag
3. Added <host>tcp://localhost:2375</host> tag
Result:
ERROR: failed to initialize docker client: failed to connect to docker socket: dial unix /var/run/docker.sock: connect: connection refused
Test 4:
1. No <host> tag
2. No <bindHostToBuilder> tag
3. Added <bindings>/var/run/docker.sock:/var/run/docker.sock</bindings> tag
Result:
DockerEngineException: Docker API call to 'localhost:2375/v1.24/containers/create' failed with status code 400 "Bad Request"
I also tried to downgrade docker daemon version and increase CPU and memory limits for the containers running the build and the docker daemon. But same result. Unluckily, I cannot find any other docker logs other the ones I listed above, it just returns 400 it seems. no debug / error log at all.
Please note that for all test cases the image is correctly pulled by the docker daemon, so communication fully work in that case (DOCKER_HOST env var is enough I assume), but the creator always fails for the reasons you can see above. Not sure if it can help. Any idea?
from spring-boot.
Unfortunately this is difficult to diagnose without access to a running environment.
Please note that for all test cases the image is correctly pulled by the docker daemon, so communication fully work in that case
This means that the Spring Boot code running locally on the host machine can talk to the Docker daemon. This is usually pretty easy to get running, as you can test local docker connectivity with the docker
CLI and other tools.
but the creator always fails...
This is the hard part, as it is requires a container running in the Docker daemon to have access to the Docker host somehow (via a socket or a remote host address), and this is entirely dependent on how things like docker-in-docker are set up by a CI platform. Users have had had other issues with environments like this.
Any idea?
Logs that show what's going on when the processes running inside the container try to access the Docker host would be helpful. Otherwise, you can see if there's a way to shell into a CI container and try docker commands to see what works (for example, what sockets are available, what permissions are on the socket, if a remote host address works).
from spring-boot.
In the end I decided to go for another direction in order to let the pipeline works, I'll explain it below.
For anyone who got the same issue, It's worth to mention that I didn't test the dind-rootless image in the setup you see above, maybe it would have fixed the issue, or maybe not: I don't know.
What I did in the end is to rely on the host machine docker daemon instead of starting up a new docker container in the Jenkins agent pod. To let it work, I just need to mount the docker socket:
apiVersion: v1
kind: Pod
spec:
volumes:
...
- hostPath:
type: Socket
path: /run/docker.sock
name: docker-sock
- hostPath:
type: Directory
path: /var/lib/docker
name: docker-lib
containers:
...
- name: maven
image: maven:3.9.6-eclipse-temurin-21
tty: true
command: [ "sleep" ]
args: [ "infinity" ]
volumeMounts:
...
- mountPath: /var/run/docker.sock
name: docker-sock
readOnly: false
- mountPath: /var/lib/docker
name: docker-lib
readOnly: false
I also got rid of DOCKER_HOST env variable and of docker host, url and bindings tags in the spring-boot-maven-plugin configuration. Everything works fine now.
from spring-boot.
@danparisi Thanks for letting us know that you found a way to get this working.
from spring-boot.
Related Issues (20)
- Upgrade to Kafka 3.6.2
- Upgrade to Lombok 1.18.32
- Upgrade to Maven Invoker Plugin 3.6.1
- Upgrade to Maven Source Plugin 3.3.1
- Upgrade to MongoDB 4.11.2
- Upgrade to Netty 4.1.108.Final
- Upgrade to R2DBC Postgresql 1.0.5.RELEASE
- Upgrade to Spring GraphQL 1.2.6
- Upgrade to Tomcat 10.1.20
- Loading of custom deny-all filter can cause a StackOverflowError when deploying to Tomcat with Log4j2 configured to use a single JVM-wide logger context
- Loading of custom deny-all filter can cause a StackOverflowError when deploying to Tomcat with Log4j2 configured to use a single JVM-wide logger context
- Provide an alternative to javadoc for documenting configuration properties HOT 3
- Facing Issue with log back Configuration HOT 2
- io.lettuce.core.RedisConnectionException: Unable to connect to [docker-server-name]/<unresolved>:6379 HOT 1
- Potentially exclude project build test scope from 'compiledWithoutParameters' validation HOT 1
- Add spring.graphql.websocket.keep-alive property
- @ServletComponentScan does not register servlet components in a mock web environment
- @ServletComponentScan does not register servlet components in a mock web environment
- When using Maven, configuring the spring-boot.excludes or spring-boot-includes user properties causes the build to fail with "Cannot find default setter"
- When using Maven, configuring the spring-boot.excludes or spring-boot-includes user properties causes the build to fail with "Cannot find default setter"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.