Jenkins
Docker image to run Jenkins.
Building
docker build -rm -t registry.codemate.se/jenkins .
Usage
It's as simple as:
docker run --privileged -d registry.codemate.se/jenkins
Note that the --privileged flag is needed since the startup script attempts to set the ulimit for open files.
Customize exposed port
By default, the port 8080 (web interface), and 8081 (jnlp port) are mapped to a random ports on the docker host. To customize, run:
docker run -p 8080:8080 -p 8081:8081 -d registry.codemate.se/jenkins
More info about port redirection can be found in the official Docker documentation.
Persist application data on the docker host
By default the application data is stored in the container in /var/lib/jenkins. You can map a directory on the host to this directory to store the application data outside of the container.
This is useful if you want to start containers using different versions of the image but with the same application data or if you want to backup this directory on the host. It also allows you to upgrade your server without losing your data:
docker run -v /data/jira:/var/lib/jenkins -d registry.codemate.se/jenkins
Overiding Jenkins files
By providing an environment variable name JENKINS_OVERLAY that points to a gzipped tar file you can apply an overlay on the Jenkins installation. This tarball will be unzipped and extracted in /var/lib/jenkins.
docker run -e JENKINS_OVERLAY=http://10.0.0.1/jenkins-config.tgz -d registry.codemate.se/jenkins
The overlay is fetched using curl so if you need to provide basic auth credentials simply prefix the url with the credentials, for example:
JENKINS_OVERLAY="-u username:password http://10.0.0.1/jenkins-config.tgz"
Combined options
The following example shows the options we use for our CI environment:
docker run --privileged -name jenkins \
-e JENKINS_OVERLAY=http://10.0.0.1/jira-config.tgz \
-v /opt/application-data/jenkins:/var/lib/jenkins \
-p 8080:8080 -p 8081:8081 \
-d registry.codemate.se/jenkins
Directories
-
/var/lib/jenkins- Jenkins home directory (JENKINS_HOME)
Variables
-
JENKINS_OVERLAY- A URL pointing to an tarball overlay
Exposed ports
-
8080- Web interface -
8081- JNLP port