Interview Prep/Jenkins/Plugins, JCasC & Jenkins on Kubernetes

What is the Docker Pipeline plugin and how is `docker.image().inside()` used?

IntermediateConceptPlugins, JCasC & Jenkins on Kubernetes
Answer

On agents with a Docker daemon, the Docker Pipeline plugin provides a Groovy API:

docker.image('node:22-alpine').inside('-v npm-cache:/root/.npm') {
  sh 'npm ci && npm test'
}
docker.withRegistry('https://registry.example.com', 'registry-creds') {
  def img = docker.build("shack-api:${env.GIT_COMMIT.take(7)}")
  img.push()
  img.push('latest')
}

inside mounts the workspace and runs the container with the agent's UID. It needs a Docker daemon on the agent, so it does not fit containerd-only Kubernetes agents.

All Jenkins questions Roadmap: Jenkins

More on Plugins, JCasC & Jenkins on Kubernetes