DinD(Docker Inside Docker)

Mount the Docker Socket and Devices

docker run -it --gpus all --runtime=nvidia \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /usr/bin/docker:/usr/bin/docker \
  -v /dev/nvidia0:/dev/nvidia0 \
  -v /dev/nvidiactl:/dev/nvidiactl \
  -v /dev/nvidia-uvm:/dev/nvidia-uvm \
  --name outer-nv-container nvidia/cuda:12.2.0-base-ubuntu22.04

Security Issue

running Docker-in-Docker (DinD) with GPU support does indeed involve passing a higher permission level from the host system into the outer container. Specifically:

1. Privileged Mode

2. Mounting the Docker Socket

3. Device Access

4. Security Implications

Conclusion

The permission level, including device access and privileged mode, is indeed passed into the DinD setup. This allows the inner Docker containers to function correctly, particularly when using specialized hardware like GPUs. However, with great power comes great responsibility—ensure that this configuration is secure and controlled.