I want to do the build of my image on a shared runner and build it on gitlab registry.

then I want to pull that image, on my server using the runner on my server using shell executor.

but I face a problem, on my shell executor when i try to run a docker command, gives me this error

$ docker info
error during connect: Get http://docker:2375/v1.37/info: dial tcp: lookup docker on no such host

here is my gitlab-ci.yml

image: docker:stable

  - docker:dind

  CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH
  DOCKER_HOST: tcp://docker:2375
  DOCKER_DRIVER: overlay2

  - build
  - deploy

  - docker info
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com

  stage: build
     - docker pull $CONTAINER_IMAGE:latest || true
     - docker build -f docker-images/web/Dockerfile --cache-from  $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_SHA --tag $CONTAINER_IMAGE:latest .
     - docker push $CONTAINER_IMAGE:$CI_COMMIT_SHA
     - docker push $CONTAINER_IMAGE:latest

  stage: deploy
    - docker pull $CONTAINER_IMAGE:latest || true
    - deploy
    - shell

I tested without the build stage, and comented the variables DOCKER_HOST and services docker:dind, and works. Execute the docker commands and works well.

I'm new on this, i think the problem is that my shell executor tries to comunicate with the docker host tcp://docker:2375, and not my docker engine.

What can I do?. I was thinking on call a shell script, and run the docker commands on this script. But I would like to do it directly on my gitlab-ci.yml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.