Pipeline fails when triggered from bridge job "cannot connect to docker daemon"

Hello,

I’m facing a problem when setting up a very simple multi-project pipeline project with 2 projects.
The important parts of Project As and Bs gitlab-ci.yml are shown below.

Project Bs purpose is to deploy docker images, that have been built in Project A, to different servers using specific gitlab-runners.
The pipeline of Project B is run successfully when run individually, eg. when triggered from a push to Project B.

When using a job in Project A as trigger, the pipeline of Project B is successfully triggered but outputs the common error when executing its script:
Couldn't connect to Docker daemon at https://172.17.0.1:2375 - is it running?
The (almost) full log is shown in the image below.

I’m using a docker in docker setup in Project B. I have already seen and successfully dealt with that message, when setting up that pipeline initially.
But since using the right setup, the pipeline has had no problem whatsoever.

So now I’m wondering why running the pipeline of Project B alone is successful, but triggering it from Project A, which in my view changes absolutely nothing in the setup, results in this error message.

I’d be very happy for any hints.

#################################

Project As gitlab-ci.yml

trigger-demo-pipeline:
stage: build
trigger:
project: cloud-edge-deployment/demo-festo-cplab
branch: feature/cicd

################################

Project Bs gitlab-ci.yml

stages:
- deploy

variables:
DOCKER_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
DOCKER_VERSION: 19.03.12

deploy-main:
image: jonaskello/docker-and-compose:19.03.12-1.26.2
stage: deploy
tags:
- nuc
services:
- docker:$DOCKER_VERSION-dind
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- ls -a
- cd main-node_festo-nuc
- ls -a
- docker-compose down --volumes
- docker-compose up -d --force-recreate
- docker-compose down --volumes
- echo “this script deploys the application for main node” %% exit 0
#####################

Job from Project-B is succesfull when triggered by ordinary push to Project-Bs repos

#####################

Job from Project-B fails when triggered by bridge-job from Project-A

Hi @n14s
I think there is something else in your setup. I noticed that in job you have cd main-node_festo-nuc, but in the job output it is cd central_cloud. Also docker login works just fine so my guess would be the .env file. What’s in the .env file? Do you set DOCKER_HOST there by any chance?

Hey, thanks for the reply.

I took a screenshot from the wrong job. ( it’s basically the same, just deploys to different server and starts a different image).
But, as you have seen, the problem is the same on every deploy job.
I updated the screenshot.

I also added a screenshot of the log of the same job, where the pipeline of Project-B executes successfully. The only difference is, that it is triggered by a ordinary push to Project-B (in contrast to the bridge trigger from Project-As pipeline).

I cannot reproduce that error on GitLab.com or self-hosted GitLab instance. It just works as it should.
I can only think of adding echo $DOCKER_HOST and docker info commands right before the docker-compose and run it with --log-level DEBUG. Compare the outputs of runs based on Push and Trigger.

Hello,
thanks for your hints.

There has indeed been a mistake in the DOCKER_HOST variable configuration.

The variable wasn’t set to “tcp://docker:2375”, which was expected and which is used for unencrypted communication with the daemon, but to “…:2376” instead, which is used for encrypted communication. After setting the DOCKER_HOST variable to “tcp://docker:2375” in the pre-script of the gitlab-ci.yml my docker-in-docker configuration worked as expected.

I hope other people struggling with this problem will find the post helpful. :slight_smile: