Learn to run build steps in Docker containers using the Docker Pipeline Plugin in Jenkins, including configuration and multi-agent examples.
In this lesson, you’ll learn how to run your build steps inside Docker containers by using the Docker Pipeline Plugin in Jenkins. We’ll explore how to configure a Docker agent via the Pipeline Syntax editor, write a Jenkinsfile that uses multiple agent types, and inspect the console output when pulling and running containers.
On your Jenkins controller or agent node, confirm there are no leftover build containers:
Copy
Ask AI
$ docker ps -a# No running containers (build containers have been removed)
You can see the pulled image still exists:
Copy
Ask AI
$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEnode 18-alpine f48cc5826852 4 months ago 128MBhello-world latest d2c94e258dcb 18 months ago 13.3kB
You’ve now seen how to configure and use Docker containers as build agents in Jenkins pipelines. This approach ensures consistent build environments, easy cleanup, and the flexibility to use any Docker image.