Interview Prep/DevSecOps/Container and IaC Security

A CI job mounts `/var/run/docker.sock` into a container to build images. Is that acceptable?

IntermediateScenarioContainer and IaC Security
Answer

Situation read → Docker socket access equals root on the host. Any process in that container can start a privileged container.

What I'd do →

  1. Replace with daemonless builders: BuildKit rootless, Kaniko, Buildah or ko.
  2. If you must use Docker, run on ephemeral VMs isolated from other workloads.
  3. Never share the socket on runners that build untrusted code from forks.
  4. Add a policy rule that rejects hostPath mounts of the socket.

Why → You remove the privilege instead of trying to monitor it.

Interview tip → Note Kaniko is now archived upstream; mention BuildKit or Buildah as current options.

All DevSecOps questions Roadmap: Policy as code

More on Container and IaC Security