What are the pitfalls of Docker socket mounting in Jenkins agents, and what are alternatives?
AdvancedProductionJenkins in Production
Answer
Mounting /var/run/docker.sock gives any job root-equivalent control of the host, since it can start privileged containers and read other builds' data. Alternatives: rootless builders (Buildah, BuildKit rootless, Kaniko forks) in pod containers, a remote BuildKit service shared across jobs, or Docker-in-Docker on isolated, short-lived nodes dedicated to image builds. Separate image-build nodes from deploy nodes and never run untrusted PR builds on a node that can reach production.
More on Jenkins in Production
How do you run Jenkins for high availability and scale?AdvancedHow do you tune the Jenkins controller JVM and avoid out-of-memory crashes?AdvancedHow do you back up and restore Jenkins?IntermediateHow do you upgrade Jenkins and its plugins safely?IntermediateHow do you harden a Jenkins controller?AdvancedHow do you configure dynamic Kubernetes agents in Jenkins for production use?Intermediate