I've stripped down bitbucket-pipeslines.yml to a minimal example that reproduces the issue:
pipelines:
default:
- step:
name: Build
image: gradle:8.7-jdk21
services:
- docker
script:
- gradle bootBuildImage
this results in the error:
Execution failed for task ':bootBuildImage'.
> Docker API call to 'localhost:2375/v1.24/containers/create' failed with status code 403 "Forbidden"
If I add an extra pipeline step, per recommendations: export DOCKER_HOST=tcp://172.17.0.1:2375
I get the similar error:
Execution failed for task ':bootBuildImage'.
> Docker API call to '172.17.0.1:2375/v1.24/containers/create' failed with status code 403 "Forbidden"
I'm using Spring Boot 3.2.4 which is the latest as of this writing. My project is mostly what is auto-generated by https://start.spring.io/
btw, on my local laptop, gradle bootBuildImage
works fine, but in the bitbucket-pipelines environment, it is failing as discussed.
I was expecting the image building to work.
You are likely to be running into the problems documented in this Spring Boot issue: https://github.com/spring-projects/spring-boot/issues/28387.
As shown there, a configuration similar to this is required to work around limitations of the BitBucket Docker configuration:
tasks.named('bootBuildImage') {
docker {
host = "tcp://172.17.0.1:2375"
bindHostToBuilder = true
buildWorkspace {
bind {
source = "/opt/atlassian/bitbucketci/agent/build/cache-${project.name}.work"
}
}
buildCache {
bind {
source = "/opt/atlassian/bitbucketci/agent/build/cache-${project.name}.build"
}
}
launchCache {
bind {
source = "/opt/atlassian/bitbucketci/agent/build/cache-${project.name}.launch"
}
}
}
}