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
2
votes
3 answers

Running docker inside a container

I am using the docker dind image and creating a pod. When I try to run docker build inside the pod, I get an error. apiVersion: v1 kind: Pod metadata: name: dockercontainer namespace: default spec: containers: …
Hanuman
  • 43
  • 5
2
votes
2 answers

Error "group docker not found" attempting to start docker:dind service in gitlab ci/cd pipeline on private runner

I am getting an error trying to run docker images in a gitlab ci/cd pipeline on a private runner. The pipline runs correctly on the shared runners. It looks like the docker:dind service is not starting. Preparing the "docker" executor Using Docker…
Debby Mendez
  • 691
  • 10
  • 16
2
votes
0 answers

Docker-in-docker inside GitHub Actions, can't access Container from within Container

I'm running my CI from within a docker container with docker installed. Inside that docker container, I'm running docker-compose with a postgres database. Even though the postgres database has fully started, I can't access it at localhost:8090, like…
spierce7
  • 14,797
  • 13
  • 65
  • 106
2
votes
1 answer

Docker in Docker - How do I start a docker container without outputting console logs from child container

I have the following problem regarding console output from Docker Containers I have built a C# console app, it lives inside a docker image that I have always running (Main Docker Container). I have mounted the docker socket to allow the container to…
2
votes
1 answer

How to prevent container exposing port to the world, but it can access to the internet?

I run a Jenkins container instance on our server with this command: docker run --name jenkins --restart=on-failure -d \ --network jenkins --env DOCKER_HOST=tcp://docker:2376 \ --env DOCKER_CERT_PATH=/jenkincerts/client --env DOCKER_TLS_VERIFY=1…
2
votes
0 answers

updates.jenkins.io: Temporary failure in name resolution while building jenkins docker image in docker in docker Jenkins agent running on K8S

I'm using dynamically provisioned docker in docker agent as Kubernetes pod in Jenkins helm chart. Docker in Docker agent uses 2 images, one with docker client, one with docker daemon. Their Dockerfile is below: dind-client FROM…
rok
  • 9,403
  • 17
  • 70
  • 126
2
votes
2 answers

Can't connect to Docker daemon in my GitLab CI pipeline

I am trying to build a super-simple CI/CD pipeline using GitLab CI. Upon running it I get presented with the error: Server: ERROR: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running? My .gitlab-ci.yml is : image:…
2
votes
1 answer

How to test in gitlab CI some code that is packaged in a Docker image, and that uses the Docker Python SDK?

I have a Python program that uses the Docker Python SDK to run a container for a third-party docker image. Something like that in my code: import docker docker.from_env().containers.run(image="") My program is also packaged in Docker,…
Adrien '
  • 21
  • 2
2
votes
0 answers

Docker Compose binding docker cli error: invalid mount config for type "bind": bind source path does not exist: /usr/local/bin/docker

I've been binding the host docker socket and cli so that I can run docker and compose commands from within running containers for over a year without issue but since updating to docker version 20.10.7 and compose version 1.29.2 I can't get my…
Alex Adams
  • 51
  • 5
2
votes
1 answer

ERROR :Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running

I am facing the below error with docker dind when running docker image ls inside container Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Below is my dockerfile FROM docker:latest RUN apk add…
2
votes
0 answers

Sharing volumes inside docker container on gitlab runner

So, I am trying to mount a working directory with project files into a child instance on a gitlab runner in sort of a DinD setup. I want to be able to mount a volume in a docker instance, which would allow me to muck around and test stuff. Like e2e…
Mr. E
  • 457
  • 1
  • 5
  • 20
2
votes
0 answers

Dind is failing with error - Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running?

We are using self hosted Gitlab and Runner and trying to use dind to run CI/CD builds but all my jobs are failing with below error - Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running? My ci file - build: …
mikita agrawal
  • 571
  • 1
  • 12
  • 27
2
votes
0 answers

Jenkins pipeline error - "No such container"

I receive a "No Such Container" error while trying to run my build in a Jenkins declarative pipeline. It is a Docker-in-Docker setup but I don't have issues running other stages of the pipeline. This problem began happening when I created a shared…
2
votes
1 answer

Gitlab's CI docker in docker login and test containers

I have a project that needs a TestContainers running to execute end2end tests. The Containers 's image is another project which docker image is pushed to GitLab's Container Registry. This means that, whenever I want to do docker pull of this image,…
dbncourt
  • 560
  • 4
  • 10
  • 27
2
votes
3 answers

How to find out which user is accessing /var/run/docker.sock that will cause permission denied error

This question is different from the following questions: Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock Because they didn't consider jenkins to be installed as docker container, here…
Tashkhisi
  • 2,070
  • 1
  • 7
  • 20