I'm trying to create a docker image of a Spring Boot application using the Gradle plugin. I'm using Spring Boot 2.6.4 and Gradle 7.1.1.
I'm on a Mac, and I don't have Docker Desktop installed. Indeed, I run docker using Colima.
The problem is that I cannot build the docker image with the command ./gradlew bootBuildImage
since Gradle cannot find the docker daemon:
Connection to the Docker daemon at 'localhost' failed with error "[2] No such file or directory"; ensure the Docker daemon is running and accessible
Is there any configuration I have to do in Colima or my build.gradle
file?
Colima creates a socket in the location ~/.colima/docker.sock
by default. Running the command docker context ls
should show a context named colima
with the socket location shown in the DOCKER ENDPOINT
column.
You can configure the Spring Boot Gradle plugin to use this socket by setting the DOCKER_HOST
environment variable to unix:///Users/<user>/.colima/docker.sock
or by adding the following to your build file as shown in the documentation.
tasks.named("bootBuildImage") {
docker {
host = "unix:///Users/<user>/.colima/docker.sock"
}
}