blob: 6eb26d3b1c948c545fe9035ea071e816ebacf879 [file] [log] [blame] [view]
Michael Neale3e124ed2014-07-18 15:12:27 +10001# Official Jenkins Docker image
Michael Neale2dedbdb2014-07-09 16:58:10 +10002
Michael Nealefe683742014-09-26 20:49:30 +10003The Jenkins Continuous Integration and Delivery server.
Michael Neale711e12e2014-07-16 11:02:46 +10004
Michael Neale3e124ed2014-07-18 15:12:27 +10005This is a fully functional Jenkins server, based on the Long Term Support release
6http://jenkins-ci.org/
Michael Neale711e12e2014-07-16 11:02:46 +10007
Michael Neale71eb3ab2014-07-09 18:04:01 +10008
Michael Neale00190fb2014-07-18 15:17:18 +10009<img src="http://jenkins-ci.org/sites/default/files/jenkins_logo.png"/>
10
Michael Neale3e124ed2014-07-18 15:12:27 +100011
12# Usage
Michael Neale71eb3ab2014-07-09 18:04:01 +100013
14```
Michael Neale709841c2014-07-14 12:16:58 +100015docker run -p 8080:8080 jenkins
Michael Neale71eb3ab2014-07-09 18:04:01 +100016```
17
Michael Nealefe683742014-09-26 20:49:30 +100018This will store the workspace in /var/jenkins_home. All Jenkins data lives in there - including plugins and configuration.
19You will probably want to make that a persistent volume (recommended):
Michael Neale71eb3ab2014-07-09 18:04:01 +100020
21```
Michael Neale709841c2014-07-14 12:16:58 +100022docker run -p 8080:8080 -v /your/home:/var/jenkins_home jenkins
Michael Neale71eb3ab2014-07-09 18:04:01 +100023```
24
Michael Nealefe683742014-09-26 20:49:30 +100025This will store the jenkins data in /your/home on the host.
26Ensure that /your/home is accessible by the jenkins user in container (jenkins user - uid 102 normally - or use -u root).
27
28
29You can also use a volume container:
30
31```
32docker run --name myjenkins -p 8080:8080 -v /var/jenkins_home jenkins
33```
34
35Then myjenkins container has the volume (please do read about docker volume handling to find out more).
36
Michael Neale3e124ed2014-07-18 15:12:27 +100037## Backing up data
38
Michael Nealefe683742014-09-26 20:49:30 +100039If you bind mount in a volume - you can simply back up that directory
40(which is jenkins_home) at any time.
Michael Neale3e124ed2014-07-18 15:12:27 +100041
Michael Nealefe683742014-09-26 20:49:30 +100042This 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 Neale3e124ed2014-07-18 15:12:27 +100043
Michael Nealefe683742014-09-26 20:49:30 +100044If your volume is inside a container - you can use ```docker cp $ID:/var/jenkins_home``` command to extract the data.
45Note 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 Neale3e124ed2014-07-18 15:12:27 +100048
49You 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 Neale2627b962014-07-21 15:52:23 +100051<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
Nicolas De Loof28d0c592014-10-01 15:07:26 +020053# Passing JVM parameters
54
55You might need to customize the JVM running Jenkins, typically to pass system properties or tweak heap memory settings. Use JAVA_OPTS environment
56variable for this purpose :
57
58```
59docker run --name myjenkins -p 8080:8080 -env JAVA_OPTS=-Dhudson.footerURL=http://mycompany.com jenkins
60```
61
Michael Neale457a91c2014-09-26 20:53:22 +100062# Installing more tools
63
Michael Neale83e5d482014-09-28 13:14:25 +100064You 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 to customise, for example:
Michael Neale3e124ed2014-07-18 15:12:27 +100065
Michael Neale83e5d482014-09-28 13:14:25 +100066```
67FROM jenkins
68USER root # if we want to install via apt
69RUN apt-get install -y ruby make more-thing-here
70USER jenkins # drop back to the regular jenkins user - good practice
Nicolas De Loof91181652014-10-04 08:31:01 +020071```
72
73In such a derived image, you can customize your jenkins instance with hook scripts or additional plugins.
74Those need to be packaged inside the executed jenkins.war, so use :
Michael Neale83e5d482014-09-28 13:14:25 +100075
76```
Nicolas De Loof91181652014-10-04 08:31:01 +020077RUM mkdir /tmp/WEB-INF/plugins
78RUN curl -L https://updates.jenkins-ci.org/latest/git.hpi -o /tmp/WEB-INF/plugins/git.hpi
79RUN curl -L https://updates.jenkins-ci.org/latest/git-client.hpi -o /tmp/WEB-INF/plugins/git-client.hpi
80RUN cd /tmp; zip --grow /usr/share/jenkins/jenkins.war WEB-INF/*
81```
82
83Also see [JENKINS-24986](https://issues.jenkins-ci.org/browse/JENKINS-24986)
84
85
Michael Neale3e124ed2014-07-18 15:12:27 +100086# Upgrading
87
Michael Nealefe683742014-09-26 20:49:30 +100088All 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 Neale3e124ed2014-07-18 15:12:27 +100089
Michael Nealefe683742014-09-26 20:49:30 +100090As always - please ensure that you know how to drive docker - especially volume handling!
Michael Neale709841c2014-07-14 12:16:58 +100091
Michael Nealefe683742014-09-26 20:49:30 +100092# Questions?
Michael Neale709841c2014-07-14 12:16:58 +100093
Michael Nealefe683742014-09-26 20:49:30 +100094Jump on irc.freenode.net and the #jenkins room. Ask!