Docker Community Forums

Share and learn in the Docker community.

Does anyone have a working example of docker-compose within docker-dind?

Hello all!

I have been trying for a while to use docker-compose with DinD and I do not manage to have it working. Does anyone have a working example?

I have the following but it fails because compose says " Path to a certificate and key files must be provided through the client_config param" which might be related to TLS.

  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: '/certs'  
    - docker
  stage: test
  image: docker:19.03.12
    - name: docker:19.03.12-dind
      alias: localhost

    - apk update && apk add --no-cache curl
    - curl -L --fail -o /usr/local/bin/docker-compose
    - chmod +x /usr/local/bin/docker-compose
    - echo "$CI_JOB_TOKEN" | docker login -u $CI_REGISTRY_USER --password-stdin $GITLAB_REGISTRY
    - cd Application/server
    - docker pull $SERVER_TESTING_IMAGE_NAME:latest || true
    - docker-compose -f ./config/docker-compose-testing.yml build --no-cache

Thank you in advance and kind regards

Enable Docker commands in your CI/CD jobs
To enable Docker commands for your CI/CD jobs, you can use:

The shell executor
The Docker executor with the Docker image (Docker-in-Docker)
Docker socket binding
If you don’t want to execute a runner in privileged mode, but want to use docker build, you can also use kaniko.

If you are using shared runners on, see shared runners to learn more about how these runners are configured.

Use the shell executor
You can include Docker commands in your CI/CD jobs if your runner is configured to use the shell executor. The gitlab-runner user runs the Docker commands, but needs permission to run them.

Install GitLab Runner.
Register a runner. Select the shell executor. For example:

sudo gitlab-runner register -n
–registration-token REGISTRATION_TOKEN
–executor shell
–description “My Runner”

On the server where GitLab Runner is installed, install Docker Engine. View a list of supported platforms.

Add the gitlab-runner user to the docker group:

sudo usermod -aG docker gitlab-runner

Verify that gitlab-runner has access to Docker:

sudo -u gitlab-runner -H docker info

In GitLab, to verify that everything works, add docker info to .gitlab-ci.yml:


  • docker info

- docker build -t my-docker-image .
- docker run my-docker-image /script/to/run/tests

You can now use docker commands (and install docker-compose if needed).

When you add gitlab-runner to the docker group, you are effectively granting gitlab-runner full root permissions. Learn more about the security of the docker group

Thanks @lewish95 !

Indeed I have all that done and I can run ok docker. However, it is docker-compose the one failing, for example I got this error when calling compose build:

compose.config.config.find: Using configuration files: ././config/docker-compose-testing.yml
compose.cli.main.main: TLS configuration is invalid - make sure your DOCKER_TLS_VERIFY and DOCKER_CERT_PATH are set correctly.

My workaround for now is to not use docker-compose and call manually all the containers with docker run as it works in this way.

Again thank you.