/Docker-in-Docker-onAWS

launch Docker Container and in this launched Container again install Docker and launch Docker Container in it. "Docker containers inside another Docker container".

Docker inside the Docker

Screenshot 2024-02-13 152226

What is DOCKER IN DOCKER?(DinD)

Docker-in-Docker means we can run Docker containers inside another Docker container.

In Docker world One process communicate with Other process is because od "Unix Socket".

Command for go Location:

cd /run/containerd/

Command for list:

ls -i

There are two ways to create Docker in Docker

  1. Lauch Container by sharing Host Docker Socket (-v /run/containerd/:/run/containerd/ )

  2. Give all capabilities to the container (--privileged) --privileged <> Give extended privileges to this container

What is Privileged capabilities:

When we create container have very limited power(not root power) or Capabilities,that not able to Launch 'New container in it',

but Running in "--privileged" mode to new container give All capabilities to Start Dockerin it .

Using 2nd method DinD (Give all capabilities to the container)

  • Prerequisite: AWS account

Step-1: [Install and Start docker service ] {DOCKER 1st}

Command for download Docker:

yum install docker -y

Command for start Docker Service:

systemctl start docker

Step-2: pull docker image (Docker provides a pre-created image for Docker inside Docker)

docker pull docker

Step-3: [lauch new Container by adding all Capabilities to the Container]

docker run -dit --privileged --name myDinD docker

Screenshot 2024-02-13 155059

Step-4: [Attach new Container(myDinD) in that Container install Docker again] {DOCKER 2 inside DOCKER1}

docker exec -it myDinD sh

Screenshot 2024-02-13 155842

Step-5: [Here Docker installed inside Container] (check in myDinD)

 docker info

Screenshot 2024-02-13 160449

All docker command run in myDinD that is 'Docker inside Docker'

  docker ps
  docker images
  docker pull docker

Screenshot 2024-02-13 160549

Step-6: [We also launch Docker in Containerized Docker] {DOCKER 3 inside DOCKER 2}

Command for run Container with --privileged:

  docker run -dit --privileged --name myDinD2 docker

Command for attach or get shell terminal of running Container:

  docker exec -it myDinD2 sh

Screenshot 2024-02-13 161159

Step-7: [Here All DinD setup Done]

1.Docker host (Docker 1)

2.myDinD container (Docker 2 inside Docker 1)

3.myDinD2 container (Docker 3 inside Docker 2)

Screenshot 2024-02-13 162357