我试图在Gitlab-ci.yaml (管道)中构建Spring应用程序的对接映像,方法是使用命令“spring: build”而不使用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]Gitlab-ci.yaml
maven-build:
image: maven:3-jdk-11
stage: build
script:
- "mvn spring-boot:build-image"
artifacts:
paths:
- target/*.jar发布于 2022-02-28 13:40:06
您必须使用码头工人服务来构建映像并通过services添加它。
maven-build:
image: maven:3-jdk-11
stage: build
services:
- docker:dind
script:
- "mvn spring-boot:build-image"
artifacts:
paths:
- target/*.jar发布于 2022-09-02 19:13:39
我遇到了同样的问题,通过设置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/*.jarhttps://stackoverflow.com/questions/71295726
复制相似问题