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
0
votes
0 answers

Docker daemon to run on another port in a container

Due to some requirement, I am using dind (docker inside docker) whose docker daemon is used by other container inside the same pod. I want to run this dind container's docker daemon on any port other than 2375. There is another pod existing inside…
Prashant Goel
  • 471
  • 4
  • 7
0
votes
2 answers

DinD as service in docker compose without TLS not working

I have created this simple docker-compose.yml where there are two services. One is the main service (ubuntu) which I want to execute docker commands isolated from docker host. The other one is the docker dind service without TLS, which should act as…
Eduardo G
  • 370
  • 4
  • 17
0
votes
3 answers

How to install Docker Desktop inside a Windows Server Core based container

Haven't come across any article that says how to setup Docker in Docker for Windows (native, not WSL). Trying to build a Windows Server Core based image but from within a Windows Server Core Container. Is this possible?
Ashik
  • 317
  • 3
  • 12
0
votes
1 answer

Run an amd64 docker-in-docker (dind) container on an arm64 host (Apple silicon machine)

I am trying to run an amd64 docker-in-docker (dind) container on an arm64 host (Apple silicon), because some images to be run on this dind are amd64 only (e.g. MySQL-5.7). Run this command on a Mac with Apple chip: docker run --platform linux/amd64…
updogliu
  • 6,066
  • 7
  • 37
  • 50
0
votes
2 answers

docker-compose in gitlab-ci: expose ports

I like to set up a gitlab repository and a gitlab-ci with docker-compose for integration tests. I finally managed to start some containers with docker-compose. image: docker/compose:1.29.2 variables: DOCKER_HOST: tcp://docker:2375/ …
0
votes
2 answers

Configure gitlab-runner, docker/compose and docker:dind to use an artifactory docker image hub mirror

There are various questions on how to use docker or docker-compose from the gitlab-ci. So I am using the following Docker-Images for my quest: gitlab/gitlab-runner:latest (as the gitlab-runner instance) docker/compose:1.29.2 (as gitlab-ci.yml…
0
votes
0 answers

Alternate for docker sock for building images

I have been using below to mount docker in my deployment file. This way From the inside of my code, I can build custom images using docker command volumeMounts: - name: dockersock mountPath: "/var/run/docker.sock" volumes: - name: dockersock …
Hacker
  • 7,798
  • 19
  • 84
  • 154
0
votes
0 answers

Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running? Gitlab-ci in private repository

I have docker-compose file which is working fine locally on my computer. I register gitlab-runner on the same pc and every pipeline where I use any docker command fails with an error: "docker: Cannot connect to the Docker daemon at…
0
votes
0 answers

How to scale docker-in-docker

I am using a docker-in-docker setup, because I am creating apps as seperated docker-container. This means that one container is spawning other containers. As far as I understood kubernetes and all other Auto-scale Cloudservices, this is not…
marius
  • 1,118
  • 1
  • 18
  • 38
0
votes
0 answers

Docker multi-stage builds stuck between layers when using Docker-in-Docker with Jenkins and Kubernetes

Big title, I know, but it is a very specific issue. I'm creating a new Jenkins cluster, and trying to use Docker-in-Docker containers to build images, differently from the current Jenkins cluster that uses that ugly-as-hell /var/run/docker.sock. The…
0
votes
1 answer

Is it possible to have a sidecar persist across multiple tasks in a Tekton pipeline?

Tekton's build-in sidecar functionality allows you to define sidecars that will run alongside a single task and stop when the task completes. The specific use-case I'm concerned with is using a Docker-in-Docker sidecar to build an image in one task,…
Hilda Hay
  • 87
  • 3
0
votes
0 answers

Base Docker in Docker image cannot start Docker daemon

I have reduced my dockerfile to the following FROM docker:latest EXPOSE 3000 But when running the image, docker daemon cannot start. Running dockerd in the container results in a large chain of info, errors and warnings ending with the…
King Dedede
  • 970
  • 1
  • 12
  • 28
0
votes
1 answer

How to creating Dockerfile with maven jdk and docker installed for jenkins pipeline

Since I could not find a docker image on dockerhub that has maven 3.8.1, open jdk 11 and docker installed, I tried to create one with a Dockerfile. I am new to this hence facing issues. Below is how my Dockerfile looks like FROM…
Andy Dufresne
  • 6,022
  • 7
  • 63
  • 113
0
votes
1 answer

How can i install jenkins by using a dockerfile?

I want to use a dind docker image as a base image and then install jenkins inside it. this is my dockerfile : ... FROM docker:20.10.11-dind-alpine3.14 USER root RUN apk add curl &&\ curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key…
0
votes
1 answer

How to control docker compose containers from within container?

I have this minimal reproducible example of a docker compose file and I want to be able to control all docker compose services from within a docker container (docker-in-docker). Example docker-compose.yml: version: '3' services: redis: image:…
DevDavid
  • 195
  • 1
  • 1
  • 18