[英]Using spring-boot:build-image in Gitlab-ci.yaml Pipeline to create a docker image
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. 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.
但是 Gitlab 的 CI/CD 管道正在抛出错误。 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]
maven-build:
image: maven:3-jdk-11
stage: build
script:
- "mvn spring-boot:build-image"
artifacts:
paths:
- target/*.jar
You must use the Docker in Docker service to build your image and add it via services
:您必须在 Docker服务中使用 Docker 来构建您的图像并通过
services
添加它:
maven-build:
image: maven:3-jdk-11
stage: build
services:
- docker:dind
script:
- "mvn spring-boot:build-image"
artifacts:
paths:
- target/*.jar
I was running into the same issue, and I was finally able to get it working by setting the DOCKER_HOST
variable.我遇到了同样的问题,我终于能够通过设置
DOCKER_HOST
变量来让它工作。 So, things would look something like this:所以,事情看起来像这样:
variables:
DOCKER_HOST: tcp://docker:2375
maven-build:
image: maven:3-jdk-11
stage: build
services:
- docker:dind
script:
- "mvn spring-boot:build-image"
artifacts:
paths:
- target/*.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.