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.
More on Plugins, JCasC & Jenkins on Kubernetes
How do you manage plugins in a reproducible way?IntermediateWhat does `jenkins-plugin-cli` resolve for you, and what flags matter?IntermediateWhy should you keep the number of plugins low?BeginnerWhat is JCasC and how is it loaded?BeginnerWhat are the top-level root elements in a JCasC file?IntermediateHow do you inject secrets into JCasC without committing them?Advanced