使用 Spring Boot Gradle 插件和 Colima 构建 Docker 映像
我正在尝试使用 Gradle 插件创建 Spring Boot 应用程序的 docker 映像。我正在使用 Spring Boot 2.6.4 和 Gradle 7.1.1。
我使用的是 Mac,并且没有安装 Docker Desktop。事实上,我使用 Colima 运行 docker。
问题是我无法使用命令 ./gradlew bootBuildImage
构建 docker 映像,因为 Gradle 找不到 docker 守护进程:
Connection to the Docker daemon at 'localhost' failed with error "[2] No such file or directory"; ensure the Docker daemon is running and accessible
是否有我必须在 Colima 或我的 build.gradle 中进行的配置
文件?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Colima 默认在
~/.colima/docker.sock
位置创建一个套接字。运行命令 docker context ls 应显示一个名为 colima 的上下文,其中套接字位置显示在 DOCKER ENDPOINT 列中。您可以通过将
DOCKER_HOST
环境变量设置为unix:///Users//.colima/docker.sock
将 Spring Boot Gradle 插件配置为使用此套接字> 或者将以下内容添加到构建文件中,如 文档。Colima creates a socket in the location
~/.colima/docker.sock
by default. Running the commanddocker context ls
should show a context namedcolima
with the socket location shown in theDOCKER ENDPOINT
column.You can configure the Spring Boot Gradle plugin to use this socket by setting the
DOCKER_HOST
environment variable tounix:///Users/<user>/.colima/docker.sock
or by adding the following to your build file as shown in the documentation.