i am trying to build a supersimple cicd 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
CodePudding user response:
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.
CodePudding user response:
Please check below things as prelim.
- Whether docker is running or not
- 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 :).
- 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 .