Docker Compose can't directly use bootBuildImage
. Instead:
Build the image:
gradle bootBuildImage --imageName=myorg/myapp
Reference it in docker-compose.yml
:
services:
backend:
image: myorg/myapp
Automate with:
gradle bootBuildImage && docker-compose up
This separates image building from Compose.
Why this approach?
bootBuildImage is a build tool, while docker-compose expects an existing image or a Dockerfile for context. By building the image first, Compose can easily use it.
Additional Notes For more details on bootBuildImage, refer to the Spring Boot Docker Guide.