| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 1 | # Official Jenkins Docker image |
| Michael Neale | 2dedbdb | 2014-07-09 16:58:10 +1000 | [diff] [blame] | 2 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 3 | The Jenkins Continuous Integration and Delivery server. |
| Michael Neale | 711e12e | 2014-07-16 11:02:46 +1000 | [diff] [blame] | 4 | |
| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 5 | This is a fully functional Jenkins server, based on the Long Term Support release |
| 6 | http://jenkins-ci.org/ |
| Michael Neale | 711e12e | 2014-07-16 11:02:46 +1000 | [diff] [blame] | 7 | |
| Michael Neale | 71eb3ab | 2014-07-09 18:04:01 +1000 | [diff] [blame] | 8 | |
| Michael Neale | 00190fb | 2014-07-18 15:17:18 +1000 | [diff] [blame] | 9 | <img src="http://jenkins-ci.org/sites/default/files/jenkins_logo.png"/> |
| 10 | |
| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 11 | |
| 12 | # Usage |
| Michael Neale | 71eb3ab | 2014-07-09 18:04:01 +1000 | [diff] [blame] | 13 | |
| 14 | ``` |
| Michael Neale | 709841c | 2014-07-14 12:16:58 +1000 | [diff] [blame] | 15 | docker run -p 8080:8080 jenkins |
| Michael Neale | 71eb3ab | 2014-07-09 18:04:01 +1000 | [diff] [blame] | 16 | ``` |
| 17 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 18 | This will store the workspace in /var/jenkins_home. All Jenkins data lives in there - including plugins and configuration. |
| 19 | You will probably want to make that a persistent volume (recommended): |
| Michael Neale | 71eb3ab | 2014-07-09 18:04:01 +1000 | [diff] [blame] | 20 | |
| 21 | ``` |
| Michael Neale | 709841c | 2014-07-14 12:16:58 +1000 | [diff] [blame] | 22 | docker run -p 8080:8080 -v /your/home:/var/jenkins_home jenkins |
| Michael Neale | 71eb3ab | 2014-07-09 18:04:01 +1000 | [diff] [blame] | 23 | ``` |
| 24 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 25 | This will store the jenkins data in /your/home on the host. |
| 26 | Ensure that /your/home is accessible by the jenkins user in container (jenkins user - uid 102 normally - or use -u root). |
| 27 | |
| 28 | |
| 29 | You can also use a volume container: |
| 30 | |
| 31 | ``` |
| 32 | docker run --name myjenkins -p 8080:8080 -v /var/jenkins_home jenkins |
| 33 | ``` |
| 34 | |
| 35 | Then myjenkins container has the volume (please do read about docker volume handling to find out more). |
| 36 | |
| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 37 | ## Backing up data |
| 38 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 39 | If you bind mount in a volume - you can simply back up that directory |
| 40 | (which is jenkins_home) at any time. |
| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 41 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 42 | This is highly recommended. Treat the jenkins_home directory as you would a database - in Docker you would generally put a database on a volume. |
| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 43 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 44 | If your volume is inside a container - you can use ```docker cp $ID:/var/jenkins_home``` command to extract the data. |
| 45 | Note that some symlinks on some OSes may be converted to copies (this can confuse jenkins with lastStableBuild links etc) |
| 46 | |
| 47 | # Attaching build executors |
| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 48 | |
| 49 | You can run builds on the master (out of the box) buf if you want to attach build slave servers: make sure you map the port: ```-p 50000:50000``` - which will be used when you connect a slave agent. |
| 50 | |
| Michael Neale | 2627b96 | 2014-07-21 15:52:23 +1000 | [diff] [blame] | 51 | <a href="https://registry.hub.docker.com/u/maestrodev/build-agent/">Here</a> is an example docker container you can use as a build server with lots of good tools installed - which is well worth trying. |
| 52 | |
| Michael Neale | 457a91c | 2014-09-26 20:53:22 +1000 | [diff] [blame^] | 53 | # Installing more tools |
| 54 | |
| 55 | You can run your container as root - and unstall via apt-get, install as part of build steps via jenkins tool installers, or you can create your own Dockerfile that has ```FROM jenkins``` at the top and add in any dependencies you may need. |
| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 56 | |
| 57 | # Upgrading |
| 58 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 59 | All the data needed is in the /var/jenkins_home directory - so depending on how you manage that - depends on how you upgrade. Generally - you can copy it out - and then "docker pull" the image again - and you will have the latest LTS - you can then start up with -v pointing to that data (/var/jenkins_home) and everything will be as you left it. |
| Michael Neale | 3e124ed | 2014-07-18 15:12:27 +1000 | [diff] [blame] | 60 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 61 | As always - please ensure that you know how to drive docker - especially volume handling! |
| Michael Neale | 709841c | 2014-07-14 12:16:58 +1000 | [diff] [blame] | 62 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 63 | # Questions? |
| Michael Neale | 709841c | 2014-07-14 12:16:58 +1000 | [diff] [blame] | 64 | |
| Michael Neale | fe68374 | 2014-09-26 20:49:30 +1000 | [diff] [blame] | 65 | Jump on irc.freenode.net and the #jenkins room. Ask! |