Interview Prep/CI/CD/Jenkins Pipelines and Agents

You need to build a Docker image from a pipeline without giving the build access to the host Docker socket.

AdvancedScenarioJenkins Pipelines and Agents
Answer

Situation read → Mounting /var/run/docker.sock gives root-equivalent access to the node.

What I'd do →

  1. Use daemonless builders: Kaniko, BuildKit rootless, or Buildah, running as a container in a Kubernetes agent pod.
  2. Example container step: /kaniko/executor --context $WORKSPACE --dockerfile Dockerfile --destination $REG/app:$TAG.
  3. Authenticate to the registry with a mounted pull-secret or short-lived credentials, and isolate build pods in their own namespace with a restricted PodSecurity level.

Why → Anyone who can run a pipeline could otherwise escape to the host through the Docker socket.

Interview tip → Mention that Kaniko is archived upstream by Google, so evaluate BuildKit or Buildah for new setups.

All CI/CD questions

More on Jenkins Pipelines and Agents