在 Gitlab-ci.yaml Pipeline 中使用 spring-boot:build-image 创建 docker 镜像
我正在尝试使用命令“spring-boot:build-image”而不使用 Dockerfile 在 Gitlab-ci.yaml (管道)中构建 Spring Boot 应用程序的 docker 映像。该命令在终端开发工作站上运行良好。但是 Gitlab 的 CI/CD Pipeline 抛出了错误。如果有人可以提供帮助,请不胜感激。
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.4:build-image (default-cli) on project buildpackdemo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.6.4:build-image failed: Connection to the Docker daemon at 'localhost' failed with error "[2] No such file or directory"; ensure the Docker daemon is running and accessible: com.sun.jna.LastErrorException: [2] No such file or directory -> [Help 1]
Gitlab-ci.yaml
maven-build:
image: maven:3-jdk-11
stage: build
script:
- "mvn spring-boot:build-image"
artifacts:
paths:
- target/*.jar
I am trying to build the docker image of a Spring Boot application in Gitlab-ci.yaml (Pipeline) by using the command "spring-boot:build-image" with out using Dockerfile. The command is working fine on terminal development work station. But the CI/CD Pipeline of Gitlab is throwing the error. Appreciate if any one can help.
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.4:build-image (default-cli) on project buildpackdemo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.6.4:build-image failed: Connection to the Docker daemon at 'localhost' failed with error "[2] No such file or directory"; ensure the Docker daemon is running and accessible: com.sun.jna.LastErrorException: [2] No such file or directory -> [Help 1]
Gitlab-ci.yaml
maven-build:
image: maven:3-jdk-11
stage: build
script:
- "mvn spring-boot:build-image"
artifacts:
paths:
- target/*.jar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,我终于能够通过设置 DOCKER_HOST 变量来使其正常工作。所以,事情看起来像这样:
I was running into the same issue, and I was finally able to get it working by setting the
DOCKER_HOST
variable. So, things would look something like this:您必须使用 Docker in Docker 服务来构建镜像并添加通过
服务
:You must use the Docker in Docker service to build your image and add it via
services
: