I have a Jenkins setup with a master and multiple worker/slave nodes. The workers are docker containers running on VMs. The containers themselves have no docker daemon running (nor installed). They mount /var/run/docker.sock
from the host for that.
When I build the image it fails to include some CA certificates I added to the build as a binding.
My application setup (Spring Boot + Gradle) is the following:
user@nb [~/dev/project]
-> % tree ./ca-certificates
./ca-certificates
└── [drwxr-xr-x 4.0K] binding
├── [-rw-r--r-- XXXK] newRootCA.pem
├── [-rw-r--r-- XXXK] newInterCA.pem
└── [-rw-r--r-- 16] type
1 directory, 4 files
user@nb [~/dev/project]
-> % cat ./ca-certificates/binding/type
ca-certificates
user@nb [~/dev/project]
-> %
I mount this folder as a binding in my gradle
task (coming from the Spring Boot Gradle plugin)
tasks.bootBuildImage {
enabled = project.hasProperty("withDocker")
...
binding("${projectDir}/ca-certificates/binding:/platform/bindings/ca-certificates")
...
}
On my local machine this works as intended.
user@nb [~/dev/project]
-> % ./gradlew build -PwithDocker
...
> Running creator
[creator] ===> DETECTING
[creator] 5 of 18 buildpacks participating
[creator] paketo-buildpacks/ca-certificates 2.4.2
[creator] paketo-buildpacks/bellsoft-liberica 8.8.0
[creator] paketo-buildpacks/executable-jar 5.3.1
[creator] paketo-buildpacks/dist-zip 4.3.0
[creator] paketo-buildpacks/spring-boot 4.7.0
...
[creator] Paketo CA Certificates Buildpack 2.4.2
[creator] https://github.com/paketo-buildpacks/ca-certificates
[creator] Launch Helper: Reusing cached layer
[creator] CA Certificates: Contributing to layer
[creator] Added 2 additional CA certificate(s) to system truststore
[creator] Writing env.build/SSL_CERT_DIR.append
[creator] Writing env.build/SSL_CERT_DIR.delim
[creator] Writing env.build/SSL_CERT_FILE.default
...
When running the build on Jenkins the output with the additional CA certificate(s) is missing. And the resulting container does not contain them.
After two days of searching now I found out, that it's because of the setup of the Jenkins slave. When the build runs, the docker daemon (which is running on the host system) does not know/have access to the project directory and hence cannot mount the folder with the pem files to the build container. It is not throwing any errors. It creates the directory /home/jenkins/workspaces/project/ca-certificates/binding
on the host system though (and then mounts the empty folder to the build container, I guess).
I think this is a general issue with volumes and docker containers in environments, where the docker daemon has no access to the filesystem of the client. I found the issue together with a colleague, that currently tests having the docker daemon installed in Minikube as an alternative to Docker Desktop on Mac and Windows.
I can only think of two solutions to this problem right now: Installing the docker daemon in all my Jenkins slaves or building and using my own builder image, that already includes the certificates.
Both solutions have their downsides. When implementing the first one I need to take care of credentials for my private registry in all my slaves. The latter would require to regularly build new releases to get updates of the builder image. Also this would then only fix this specific case, where I need those three specific files in the container.
Do you have any other idea?
Thanks in advance!