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
5
votes
1 answer

Execute external bash script inside GitLab-ci Docker build

I would like to execute an external (on the local machine) bash script from gitlab-ci.yml which uses the docker:stable image. I would like to execute startup.sh located outside the gitlab docker image. Is this possible or are there better options?…
BobbyOrlando
  • 148
  • 1
  • 2
  • 8
5
votes
0 answers

Unable to pull from ECR within Docker Build

I am running into credential issues when I am trying to pull an image from ECR as part of a Docker Build, using AWS CodeBuild. For context, our setup is this: Codebuild is calling an internal docker tool that we wrote. This tool is then doing the…
Jon Heckman
  • 420
  • 2
  • 7
  • 18
5
votes
2 answers

Run a docker container from an existing container using docker-py

I have a Docker container which runs a Flask application. When Flask receives and http request, I would like to trigger the execution of a new ephemeral Docker container which shutdowns once it completes what it has to do. I have read…
Alexis.Rolland
  • 5,724
  • 6
  • 50
  • 77
5
votes
1 answer

How to run docker image in Kubernetes pod?

How can I run a docker image in a kubernetes pod? A teammate of mine has defined a new docker image and pushed it to my team's private registry. I own some code running in our kubernetes cluster and we need to get my code to effectively docker run…
Paymahn Moghadasian
  • 9,301
  • 13
  • 56
  • 94
5
votes
2 answers

Install Docker using a Dockerfile

I have a Dockerfile that looks like this: # Pull base image FROM openjdk:8 ENV SCALA_VERSION 2.12.2 ENV SBT_VERSION 0.13.15 # Scala expects this file RUN touch /usr/lib/jvm/java-8-openjdk-amd64/release # Install Scala ## Piping curl directly in…
joesan
  • 13,963
  • 27
  • 95
  • 232
4
votes
2 answers

overlay2 driver not supported

I am running a GitHub agent inside AKS cluster with Docker installed. I can run it successfully with VFS storage driver, however I want to use Overlay 2 because it's faster. I get the following message: sudo dockerd…
Nosheep
  • 493
  • 1
  • 4
  • 10
4
votes
0 answers

Mounting a volume with gitlab docker:dind services

I have an issue with gitlab runner using docker:dind service. I'm trying to run a docker-compose file with simple volume on a job, here the job : test_e2e: image: tmaier/docker-compose stage: test services: - docker:dind variables: …
mhlsf
  • 303
  • 4
  • 14
4
votes
1 answer

How to use docker inside jenkins pipeline without using docker-in-docker

The author of docker-in-docker suggested not to use this image for CI purposes here in this blog: jpetazzo/Using Docker-in-Docker for your CI or testing environment? Think twice Why Jenkins uses docker-in-docker in Jenkins user Handbook(installing…
Tashkhisi
  • 2,070
  • 1
  • 7
  • 20
4
votes
3 answers

Use of docker:dind in docker-compose

So for some reason, I'd like to use a docker:dind inside a docker-compose.yml. I know that the "easy" way is to mount directly the socket inside the image (like that : /var/run/docker.sock:/var/run/docker.sock) but I want to avoid that (for security…
Pacifuras
  • 116
  • 1
  • 6
4
votes
0 answers

Why does Multi-stage docker build get stuck at "COPY --from=builder ..."

The context is as follows: Jenkins Kubernetes plugin Docker-in-Docker/dind container Multi-stage Dockerfile The flow looks as follows: pull builder docker pull repo/image:builder build builder DOCKER_BUILDKIT=1 docker build . --build-arg…
Gabriel Stein
  • 428
  • 1
  • 4
  • 22
4
votes
1 answer

GitLab CI: how to connect to the docker container started in .gitlab-ci.yml script?

Initial task In my GitLab CI build, I want to: Start a docker container with local AmazonDB. Standard port layout: port 8000 in docker, port 8000 exposed. Of course, everything works locally, I can connect (curl, awc-cli, Java code for Amazon DB,…
Dmitriy Popov
  • 2,150
  • 3
  • 25
  • 34
4
votes
1 answer

packer docker builder configure docker in docker image

I'm trying to provision docker:dind image with packer which will build another docker image and run it inside docker with following build script: { "builders": [ { "type": "docker", "image": "docker:dind", "privileged":…
Mariusz Miesiak
  • 638
  • 1
  • 6
  • 19
4
votes
1 answer

Gitlab CI run code quality not generate .json file

I followed the official guid deploied a pipline to analyse my code quality. Although the pipline passed and the job successed, the json file didn't generated by docker. And these notis displaied: WARNING: A new version (v0.83.0) is available.…
fajin yu
  • 153
  • 1
  • 7
4
votes
2 answers

Cannot access K8s dashboard after installation of kubeadm-dind-cluster

I am using kubeadm-dind-cluster a Kubernetes multi-node cluster for developer of Kubernetes and projects that extend Kubernetes. Based on kubeadm and DIND (Docker in Docker). I have a fresh Centos 7 install on which I have just run…
TheEdge
  • 9,291
  • 15
  • 67
  • 135
4
votes
3 answers

How to set proxy in docker-in-docker (dind) in gitlab CI

I am trying to set up a job with gitlab CI to build a docker image from a dockerfile, but I am behind a proxy. My .gitlab-ci.yml is as follows: image: docker:stable variables: DOCKER_HOST: tcp://docker:2375 DOCKER_DRIVER: overlay2 HTTP_PROXY:…
Pedro A
  • 3,989
  • 3
  • 32
  • 56
1 2
3
18 19