[英]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. 該命令在終端開發工作站上運行良好。 但是 Gitlab 的 CI/CD 管道正在拋出錯誤。 感謝任何人可以提供幫助。
[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
您必須在 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
我遇到了同樣的問題,我終於能夠通過設置DOCKER_HOST
變量來讓它工作。 所以,事情看起來像這樣:
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.