Ensuring Jenkins has a reliable, scalable, and flexible job slaves is a challenge. The Docker Ephemeral Cloud plugin provides an elastic pool of slaves, using Docker containers, that live only as long as the job.
- Elastic slaves. An executor pool that scales to demand.
- Perfect isolation. Builds are always executed in a clean environment, isolated from others.
- Low maintenance. No always-on slaves to maintain.
- Easy build environments. Environments packaged and shared as Docker images.
- Focus on builds and stateless jobs.
When a job is scheduled, Jenkins checks for Docker image configurations that match the labels of the job. When one is found, Docker is invoked via REST APIs to pull the image and run the container. Within the container, the Jenkins JNLP slave jar is downloaded and run. Communication is established to the Jenkins master and the new slave node performs the requested job. When complete, the container is stopped and removed.
- Use Docker containers as Jenkins slaves.
- No open ports required. Containers 'phone home' via Jenkins JNLP slave connections.
- Supports multiple Docker images using slave label mappings.
- Connect via UNIX socket or remotely over REST. TLS supported.
- Completely stateless. One executor, one job run per container life.
- Recommend Jenkins 1.609.3 or newer.
- Jenkins URL is correctly set in global configuration.
- JNLP slave ports are enabled and open.
- Recommend Docker 1.7+
- Docker is configured and able to access the registries hosting the images.
- Recommend using TCP + TLS for secure, remote communication.
- Containers can reach the Jenkins master via the JNLP port.
- Contains a Java install compatible with Jenkins with java on the path. Used for invoking Jenkins slave jar.
- Contains curl, on the path. Used for downloading the slave jar
-
Add a Docker Ephemeral Cloud configuration in your Jenkins global configuration. ![Cloud Configuration] (cloud_config.png)
-
Add a Docker image to use as a base for slave containers. ![Image Configuration] (image_basic_config.png)
-
Run a job. You will see slaves come move through various states as they create, run, and destroy. ![Build executors] (build_executors.png)
-
Slaves no longer able to connect via JNLP or see deadlocked threads in node provisioning: You may be encountering JENKINS-24155. Set system property
-Djenkins.slaves.NioChannelSelector.disabled=true
as a workaround. -
Jenkins too slow to request new slaves: Try setting system property
-Dhudson.model.LoadStatistics.clock=10000
to smaller values to instruct Jenkins to calculate the need for slaves more often.10000
is the default. -
Docker Ephemeral Cloud plugin is built using Spotify's docker-client library. Please see their issues page for possible limitations and known issues.
Special thanks to Spotify and other contributors to docker-client. The docker-client library is clean and intuitive, making this project a pleasure to write.