Docker In Docker is a container pattern where a Docker engine runs inside another container so jobs can build and run additional containers. In ARC, it is the least secure mode because it depends on privileged Kubernetes configuration, which expands the blast radius if untrusted workflow code is executed.
How Docker In Docker Works
Docker In Docker, often shortened to DinD, means a container launches and runs its own Docker engine so build jobs can start sibling containers, run test environments, or perform image operations inside the job boundary.
The pattern is attractive in CI/CD because it gives the pipeline a familiar Docker-native workflow without requiring the host runner to do every container operation directly. That convenience is also why DinD is usually treated as a special-case build mode rather than a default runtime pattern, especially when the workload is not fully trusted.
Because the inner engine has to manage containers from inside another container, the setup typically depends on elevated Linux capabilities, access to the host Docker socket, or a privileged Kubernetes configuration. Those implementation details materially shape the security profile more than the name of the pattern itself.
Why It Is Considered the Least Secure Mode in ARC
In ARC, DinD is described as the least secure mode because it expands the trust boundary around the build environment. If untrusted workflow code runs with a privileged Docker path, it can do far more than assemble an image, it can often influence the container runtime, the filesystem boundary, and in some deployments the host itself.
This is a classic case where the security concern is not Docker as a technology, but the combination of nested container execution and privileged orchestration. The larger the privilege needed for the inner engine, the more severe the blast radius if the build job is malicious, compromised, or simply buggy.
For a broader container security baseline, NIST SP 800-190 Container Security is the most directly relevant external reference, because it treats image, runtime, and orchestrator risk as connected control surfaces. Where the pattern is used to build software, provenance and build integrity concerns also align with SLSA.
Security Implications and Control Boundaries
DinD affects isolation, secret handling, and the credibility of the build environment. If the inner Docker daemon can mount volumes, start containers with broad permissions, or access cached credentials, then a compromised job may expose artifacts, secrets, or registry trust relationships that were never meant to be reachable from the pipeline task itself.
That is why container hardening guidance, runtime restriction, and strict separation between build trust levels matter so much here. For practitioners looking for the secrets angle behind containerised build systems, Docker Hub Auth Secrets in Container Images and Massive Docker Hub Secrets Leak show how container workflows can accidentally turn build convenience into credential exposure. In the same spirit, NIST Cybersecurity Framework 2.0 provides the broader govern, protect, detect, respond, recover structure that helps teams classify and reduce the risk.
Because DinD is usually chosen for a specific operational reason, the practical question is not whether it works, but whether the build task really needs nested daemon control or only isolated container execution. In many environments the safer answer is to keep the build primitive as small as possible and avoid granting the inner engine more authority than the pipeline truly needs.
How Teams Usually Reduce DinD Exposure
Most safer designs aim to remove the privileged inner daemon, restrict who can run the pattern, or replace it with a lower-trust build method when possible. The key idea is to separate “can build containers” from “can control a container runtime with elevated permissions.”
When the pattern is unavoidable, teams usually treat it as a tightly scoped exception, not a general-purpose runtime choice. That means explicit ownership, clear trust assumptions, and careful attention to where images, credentials, and build outputs can move during execution. For identity-bearing material used by build systems, the NHI perspective is useful because secrets and tokens in pipelines behave like high-value access material even when no human is involved. Ultimate Guide to NHIs is a useful companion reference for that governance lens.
Risk and Threat Considerations
DinD creates an attractive escalation path because the inner Docker engine can become a bridge from untrusted build code to broader runtime control. The main risk is not just accidental breakage, but privilege abuse: a malicious job may try to inspect mounted files, reach cached secrets, manipulate sibling containers, or exploit the widened trust boundary created by privileged execution.
Failure mechanism: The pattern depends on elevated container permissions or a powerful socket path, so compromise of the build job can translate into control over the Docker daemon, adjacent containers, or poorly isolated host resources.
Impact: A successful abuse path can expose secrets, corrupt build outputs, undermine image integrity, and in the worst case expand from pipeline compromise into broader infrastructure compromise.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
CIS Controls v8 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| CIS Controls v8 | CIS 6 — Access Control Management | DinD relies on tightly controlled elevated access paths and privileged execution. |
| CIS 4 — Secure Configuration of Enterprise Assets and Software | Privileged container and orchestrator settings determine DinD exposure. | |
| CIS 8 — Audit Log Management | Build and container runtime activity must be observable when nested engines are used. | |
| Recommendation — Restrict privileged build access and revoke unnecessary runtime permissions. Harden container and Kubernetes settings to minimize privileged DinD configurations. Collect and review container runtime logs for suspicious build activity. | ||
| NIST CSF 2.0 | PR.AC-4 — Access Permissions and Least Privilege | DinD security depends on limiting who can run privileged container workflows. |
| PR.DS-1 — Data-at-Rest Is Protected | Build jobs may handle secrets, images and artifacts that need protection inside the pipeline. | |
| DE.CM-8 — Vulnerability Scanning | Nested container builds benefit from scanning images and build outputs for weaknesses. | |
| Recommendation — Apply least-privilege access to privileged build and orchestration paths. Protect build artifacts and embedded secrets from exposure during containerized builds. Scan build images and pipeline artifacts for exploitable configuration issues. | ||
Practitioner Guidance
Governance implication: Treat DinD as an exception architecture and assign an owner who can justify why nested Docker is required for the specific workflow. The security decision should be explicit because the pattern changes the trust model, not just the implementation detail.
What to watch for: Review whether the workflow really needs privileged Docker access, whether untrusted code can reach the build environment, and whether registry credentials or other secrets are available during the job. If those conditions are present, the pattern deserves the same scrutiny you would apply to any other elevated execution path.
Related resources from NHI Mgmt Group
- What does the hardcoded credential in a Docker image breach scenario teach us?
- How should security teams manage secrets in Docker images?
- What is the difference between Docker Secrets and BuildKit secret mounts?
- Should organisations scan Docker images for secrets if they already secure the source code?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on September 17, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org