Questions tagged [docker-in-docker]

Docker-in-Docker (DinD) is an unusual approach to run Docker containers by running a nested Docker daemon inside another container.

"Docker-in-Docker" (DinD) is an unusual approach to running Docker containers: instead of using docker run normally, an operator can run the Docker Hub docker image to run a second Docker daemon inside a container, and then launch containers inside that nested Docker daemon.

For most practical purposes, if a container needs to launch another container, it can use the host's Docker socket

docker run -v /var/run/docker.sock:/var/run/docker.sock ...

This approach is sometimes referred to as "Docker-out-of-Docker", in contrast to the nested Docker-in-Docker setup.

Jérôme Petazzoni's blog post Using Docker-in-Docker for your CI or testing environment? Think twice. describes some of the advantages and challenges of a DinD setup. That post notes:

The primary purpose of Docker-in-Docker was to help with the development of Docker itself. Many people use it to run CI (e.g. with Jenkins), which seems fine at first, but they run into many “interesting” problems that can be avoided by bind-mounting the Docker socket into your Jenkins container instead.

Some CI systems, notably , have native DinD support. Consider tagging your question with both and a CI-specific tag if your question is about setting up a DinD-based CI system.

The tag should be used on questions about a DinD setup. It does not describe questions about sharing the host's Docker socket. In most cases these questions will also be tagged with . Remember that Stack Overflow questions must be programming related: questions about setting up CI systems or copying images between Docker daemons are likely not on-topic.

276 questions
323
votes
5 answers

Is it ok to run docker from inside docker?

I'm running Jenkins inside a Docker container. I wonder if it's ok for the Jenkins container to also be a Docker host? What I'm thinking about is to start a new docker container for each integration test build from inside Jenkins (to start…
Johan
  • 37,479
  • 32
  • 149
  • 237
31
votes
3 answers

Docker Container Networking with Docker-in-Docker

I would like to network with a child docker container from a parent docker container, with a docker-in-docker setup. Let's say I'm trying to connect to a simple Apache httpd server. When I run the httpd container on my host machine, everything works…
Adam Snyder
  • 405
  • 1
  • 5
  • 7
22
votes
2 answers

How do i cache in gitlab ci while building docker images with docker:dind

I have a gitlab-ci.yml like this: build and push docker image: stage: publish variables: DOCKER_REGISTRY: amazon-registry AWS_DEFAULT_REGION: ap-south-1 APP_NAME: sample-app DOCKER_HOST: tcp://docker:2375 image: name:…
ssbb191
  • 1,486
  • 3
  • 12
  • 23
19
votes
2 answers

Connecting to docker-in-docker from a GitLab CI runner

I have a GitLab pipeline that I want to: Build a Java app Test using docker-compose Push to my Docker repository The primary issue I'm having is that this works: services: - docker:dind docker_test: stage: docker_test image: docker:latest …
Craig Otis
  • 31,257
  • 32
  • 136
  • 234
16
votes
1 answer

Provide SSL certificate for dockerd for own docker registry

how to provide own CA Root certificate and SSL Client certificate (cert + key) to dockerd in gitlab-ci pipeline for own docker registry? I have virtual machine (CentOS 7) and installed docker and gitlab-runner. The runner is registred as…
Mazel Tov
  • 2,064
  • 14
  • 26
14
votes
1 answer

gitlab-ci docker-in-docker access to insecure registry

When configuring a gitlab-ci for building docker images and pushing them to my gitlab's insecure registry, I encountered several errors. My gitlab-ci.yaml is laid out below: stages: - build - deploy variables: GIT_SUBMODULE_STRATEGY:…
mcguip
  • 5,947
  • 5
  • 25
  • 32
13
votes
3 answers

Permission denied error invoking Docker on Mac host from inside Docker Ubuntu container as non-root user

I'm trying to invoke docker on my OSX host running Docker for Mac 17.06.0-ce-mac17 from inside a running jenkins docker container (jenkins:latest), per the procedure described at…
mxyzplk
  • 254
  • 1
  • 2
  • 10
12
votes
1 answer

How to run dockerd in the background without logs

I am using franela/dind image to get a bash: docker run --rm --privileged -it franela/dind bash *make sure to remove /etc/docker/daemon.json before running dockerd. Inside it I ran dockerd and it start to print lots of logs: …
E235
  • 11,560
  • 24
  • 91
  • 141
12
votes
3 answers

Docker in Docker - volumes not working: Full of files in 1st level container, empty in 2nd tier

I am running Docker in Docker (specifically to run Jenkins which then runs Docker builder containers to build a project images and then runs these and then the test containers). This is how the jenkins image is built and started: docker build --tag…
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
10
votes
1 answer

GitLab CI - Trying to use docker buildx to build for ARM64

Trying to use docker buildx with GitLabs shared runners to build a Docker image that can be run on my Raspberry Pi. Job fails saying git is not in PATH but git is installed in image: docker:stable-git. Any known fixes or a better way to build an…
Adeithe
  • 334
  • 1
  • 4
  • 13
10
votes
3 answers

How do I run Docker in Docker on Heroku?

Why? I'm trying to create a general purpose solution for running docker-compose on Heroku. I want to make a one click deployment solution through the use of Heroku Button deployment. This way, a user does not need any knowledge of git, Heroku cli…
Tin Nguyen
  • 5,250
  • 1
  • 12
  • 32
8
votes
1 answer

Cache Layers in GitLab Runner Docker Executor - Long Time DinD Container

I'm working on GitLab CI at my project, and I created an image to make my tests and builds. When I ran it in docker executor every job needs to download images from the beginning. I need to cache layers and pulled images to improve my build and…
8
votes
2 answers

Pre-pull images in Docker in Docker (dind)

I am running a docker-in-docker container that always uses the same few images. I would like to pre-pull those in my dind container so I don't have to pull them at startup. How would I be able to achieve this? I was thinking of building my own dind…
Maarten Dhondt
  • 577
  • 1
  • 9
  • 22
8
votes
2 answers

Why docker in docker (dind) containers mount volumes with host path?

I have a setup with docker in docker and try to mount folders. Let's say I have those folders that I wish to share with his parent. On the host, I created a file in /tmp/dind called foo. Host starts container 1, which starts container 2. This is the…
David Bensoussan
  • 2,887
  • 2
  • 38
  • 55
8
votes
0 answers

GitLab CI dind times out

I have a GitLab installation running in Kubernetes, and suddenly, my connections to dind have stopped working. This problem started appearing in a single project out of ~30 and is working in the other ones, and no change has been made. The builds…
1
2 3
18 19