可以在我的gitlab ci管道中连接到docker守护程序

发布于 2025-02-03 12:12:40 字数 622 浏览 4 评论 0原文

我正在尝试使用Gitlab CI构建超简单的CI/CD管道。 运行它后,我会出现错误:

Server:
ERROR: Cannot connect to the Docker daemon at tcp://docker:2375.
Is the docker daemon running?

我的.gitlab-ci.yml是:

image: docker:latest
variables:
  DOCKER_HOST: tcp://docker:2375
services:
  - name: docker:dind
    entrypoint: ["env", "-u", "DOCKER_HOST"]
    command: ["dockerd-entrypoint.sh"]


before_script:
  - docker --version
docker_build:
  stage: build
  image: docker:latest
  services:
    - docker:dind
  script:
    - docker build -t arieltar/hubsec:1.1 .
    - docker push arieltar/hubsec:1.1

I am trying to build a super-simple CI/CD pipeline using GitLab CI.
Upon running it I get presented with the error:

Server:
ERROR: Cannot connect to the Docker daemon at tcp://docker:2375.
Is the docker daemon running?

My .gitlab-ci.yml is :

image: docker:latest
variables:
  DOCKER_HOST: tcp://docker:2375
services:
  - name: docker:dind
    entrypoint: ["env", "-u", "DOCKER_HOST"]
    command: ["dockerd-entrypoint.sh"]


before_script:
  - docker --version
docker_build:
  stage: build
  image: docker:latest
  services:
    - docker:dind
  script:
    - docker build -t arieltar/hubsec:1.1 .
    - docker push arieltar/hubsec:1.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

桃扇骨 2025-02-10 12:12:40

基于我要问的错误消息,gitlab-runner用户是否属于docker组?

您将需要确定是否要与TLS一起使用Docker-In-Docker。这需要更改/etc/gitlab-runner/config.toml设置,并在您的.gitlab-ci.yml文件中分配docker_tls_tls_certdir。请参阅 docker in gitlab文档的a>。

Based on the error message I would ask, does the gitlab-runner user belong to the docker group?

You will need to decide if you want to use Docker-in-Docker with, or without TLS. This requires changing /etc/gitlab-runner/config.toml settings, and assigning the DOCKER_TLS_CERTDIR in your .gitlab-ci.yml file. See the Docker-in-docker section of the GitLab docs.

[浮城] 2025-02-10 12:12:40

请检查以下内容以Prelim。

  1. 如果您是否正在使用
  2. Gitlab-user登录Docker,如果您使用Gitlab用户运行管道,并检查该用户是否可以访问或运行docker ps,而没有sudo :)。
  3. 如果PT1,请添加以下条目。和PT2满足。

服务:

  • 姓名:Docker:Dind
    入口点:[“ dockerd-entrypoint.sh”,“ - tls = false”]
    脚本:
  • export docker_host = tcp://127.0.0.1:2375&& Docker Build -T Arieltar/Hubsec:1.1。

Please check below things as prelim.

  1. Whether docker is running or not
  2. Login with gitlab-user if you are running pipeline with gitlab user and check if that user can access or run docker ps without sudo :).
  3. add below entry if pt1. and pt2 satisfied.

services:

  • name: docker:dind
    entrypoint: ["dockerd-entrypoint.sh", "--tls=false"]
    script:
  • export DOCKER_HOST=tcp://127.0.0.1:2375 && docker build -t arieltar/hubsec:1.1 .
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文