skip to Main Content

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

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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 .
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search