Today’s IT Industry is all about Containerization. No Company wants their Development Team or Testing Team to spend half of their time spinning up new Virtual Machines for creating Isolated Systems. This could awfully decrease the throughput of the Company.
The Industry is using Tools like CRI-O, Podman, Rocket, and Docker. Docker is a software platform for building applications based on containers — small and lightweight execution environments that make shared use of the operating system kernel but otherwise run in isolation from one another. Here’s another fun practical on Docker
In this article, we will be creating a docker container inside another docker container.
Create a Docker Image of Docker
docker pull docker
Create a container using this Image
docker run -it --name c_001 -v /var/run/docker.sock:/var/run/docker.sock docker
We are mounting the docker socket to the container created using the docker image. docker.sock is the UNIX socket that the Docker daemon is listening to. It's the main entry point for Docker API. This file can be used to communicate with the daemon from within a container. Docker-cli client uses this socket to execute docker commands by default.
Finally, Let’s create a container inside this container
Stopping/Terminating the Parent Container will automatically stop all the containers that were running inside the container.