Skip to content

DinD with docker-compose #303

Closed
Closed
@augustobmoura

Description

@augustobmoura

After following the guide in https://hub.docker.com/_/docker/ I wrote this docker-compose.yaml that should setup the same as the shell commands (if I understood it correctly):

version: "3.8"

services:
  dind:
    image: docker:dind
    privileged: true
    environment:
      DOCKER_TLS_CERTDIR: /certs
    networks:
      - docker
    volumes:
      - docker-certs-ca:/certs
      - docker-certs-client:/certs/client

  docker-client:
    image: docker
    environment:
      DOCKER_TLS_CERTDIR: /certs
    # Just loop at infinitum, we will get to this container by `docker exec`ing
    command: [sh, -c, "while sleep 1; do :; done"]
    networks:
      - docker
    depends_on:
      - dind
    volumes:
      - docker-certs-client:/certs/client:ro

volumes:
  docker-certs-ca:
  docker-certs-client:

networks:
  docker:

After running docker-compose exec docker-client docker version I got the following error, and I cannot connect to the dind docker from the docker-client:

Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:14:11 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Is there anything I'm missing in my docker-compose.yml?

Running the commands from the README manually I get the correct result

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions