简体   繁体   English

在 Gitlab-ci.yaml 管道中使用 spring-boot:build-image 创建 docker 镜像

[英]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]

Gitlab-ci.yaml Gitlab-ci.yaml

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.

相关问题 无法获取.reference 以在.gitlab-ci.yaml 中工作 - Cannot get !reference to work in .gitlab-ci.yaml 从 Gitlab CI 管道运行 Postman 的 Docker 映像 - Running Docker image of Postman from Gitlab CI pipeline 上传 docker 图像 gitlab ci/cd Java Z38008DD81C2F4D7985ECF6E0CE8 - Upload docker image gitlab ci/cd Java Spring 如何使用 Gitlab CI 在工作期间跨两个阶段保持 docker 映像构建? - How to keep docker image build during job across two stages with Gitlab CI? 将 maven 依赖项存储在 Gitlab CI 测试作业的 Docker 映像中 - Store maven dependencies in Docker image for Gitlab CI test job 如何将 Docker 映像从 GitLab CI 注册表部署到 Amazon ECS? - How to deploy a Docker image from GitLab CI registry to Amazon ECS? 尝试更新 my.gitlab-ci.yml 文件以运行 SAST 并且管道失败(无法提取图像) - Trying to update my .gitlab-ci.yml file to run SAST and the pipeline fails (Failed to pull image) Gitlab CI 不会将更新的 docker 图像从 cr 拉到 EC2 - [图像] 是最新的 - Gitlab CI doesn't pull updated docker image from cr to EC2 - [image] is up-to-date 在 gitlab 管道作业中使用 yq 图像时出错 - Error when using yq image in gitlab pipeline job 如何使用 Google Ko 构建和推送 Go 映像?你能告诉我 cloudbuild.yaml 创建映像并使用 Google 推送 go 映像的步骤吗? - How to build and push Go image using Google Ko?Could you tell me the steps for cloudbuild.yaml to create the image and push go image using Google ko?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM