简体   繁体   中英

Running docker-compose against docker-in-docker (dind)

In gitlab-ci, I am trying to run docker-compose within a Docker container. I am using Docker-in-Docker for this. To test that everything is working, I just execute a docker info command. However, when I use the docker-compose image as my image, I get the following error when executing docker info :

ERROR: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?

If I use docker itself as the image, the docker info command succeeds. I'm confused by this since the docker-compose image is based on the docker image.

The following.gitlab-ci.yml results in an error from the docker info command:

image: docker/compose:debian-1.26.0

stages:
  - test

variables:
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: "/certs"

services:
 - docker:19.03.8-dind

test-provider:
  stage: test
  script:
    - docker info

If I change the image to docker:19.03.8 , the docker info command runs fine. Not sure what I'm doing wrong here.

Try to start dockerd in script section explicity. Also you can add script to wait when docker daemon starting succeed. Something like:

sudo dockerd & timeout -t 9 bash -c "while [ ! -S /var/run/docker.sock ]; do sleep 3 && ls -lah /var/run/; done" || exit 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM