Jenkins Slave With Docker Executors
Docker Plugin enables jenkins to run jobs as docker container. In such case we dont need to setup jenkins nodes(agents) with specific binaries, instead docker images will be used to run jobs.Jenkins master needs to be configured with docker host where we can push docker images, those will be used by agents to execute jobs.
Global Configuration
After installation of Docker Plugin
from manage plugins options, we will need to configure docker host and templates to create docker executers in Global Configuration option.
Go to Global Configurations –> Docker –> fill the below configuration options to setup docker host
Name Name of docker slave to be used in job configuration
Docker Url docker engine url and port
Docker Template docker template is an executor, we can add multiple templates and it will enable multiple executors
Fill below configurations to setup docker template
- Docker Image image name that that is available on docker host and having binaries to run the job
- Container Settings > Volumes Provide the container volumes(ie.
/home/dockerslave/bin
) where the binaries available, these are mapped with host machine and binaries will be available on host machine to run the job. - Label Provide the label to uniquely identify the executor and configure in job configuration
- Launch Method select Docker ssh compute launcher
- Credentials select credential id to ssh into docker host container
Job Configuration
Build > check Restrict where this project can be run > Label Expression > provide the docker template lable