Pra*_*sad 8 maven spring-boot gitlab-ci
我正在尝试使用命令“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]
Run Code Online (Sandbox Code Playgroud)
maven-build:
image: maven:3-jdk-11
stage: build
script:
- "mvn spring-boot:build-image"
artifacts:
paths:
- target/*.jar
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,我终于能够通过设置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
Run Code Online (Sandbox Code Playgroud)
您必须使用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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3338 次 |
最近记录: |