The tutorial for this makefile can be found here: http://engineering.riotgames.com/news/building-jenkins-inside-ephemeral-docker-container
This tutorial contains all the files necessary to create your own local Docker-Toolbox version of a fully ephemeral jenkins environment. Build slaves are designed to be docker containers in this configuration. The only thing missing to make it work is your Docker Machine certs (see directions below on how to add these).
Ideally you'll follow along with the entire blog series. However if you'd like to get this up and running as quickly as possible here's the steps you need to do:
- Make sure you have all the pre-reqs installed (i.e. Docker-toolbox)
- Clone this repository to your local drive
- Find the docker-machine folder container your 4 client pem keys (ca-key.pem, ca.pem, key.pem, cert.pem). Mine for example, is in ~/.docker/machine/certs.
- cp -R yourdockermachinecertsfolder jenkins-master/certs
- make build
- make run
- Point your browser to http://yourdockermachineip
- In jenkins, configure a ssh-key pair using an ssh private key for the user "jenkins". As the private key, use the file in jenkins-slave/files/dummy_private_rsa_key
- In jenkins, configure a Docker Certificates Directory credential using /usr/local/etc/jenkins/certs as the source directory
- In jenkins configuration, add a new Docker cloud provider
- Set host to https://yourdockermachineip:2376
- Select the docker certificates directory you made
- Set read timeout to 5
- set connection timeout to 15
- Click on "Test COnnection" and make sure you get a valid response
- In jenkins config on your new Docker cloud add a Docker template
- Set the image name to: jenkins_slave
- Create a label "testslave"
- Make sure credentials are your new ssh key pair you made above
- Click "Save"
- Create a new free-style jenkins job
- Restrict the job to the label "testslave"
- Add a build step, like execute shell "echo 'Hello World!'"
- Save job
- Run job
If everything is configured correctly your job should dynamically allocate a slave, run itself and then de-allocate the slave.