Skip to content

Commit fe68374

Browse files
committed
Small improvements and tidying up - deferred slave port setting
1 parent ac33d00 commit fe68374

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ FROM ubuntu:14.04
33
RUN echo "1.565.2" > .lts-version-number
44

55
RUN apt-get update && apt-get install -y wget git curl zip && apt-get clean
6-
RUN apt-get update && apt-get install -y --no-install-recommends openjdk-7-jdk && apt-get clean
7-
RUN apt-get update && apt-get install -y maven ant ruby rbenv make && apt-get clean
6+
RUN apt-get update && apt-get install -y --no-install-recommends openjdk-7-jdk && apt-get clean bash
87

98
RUN wget -q -O - http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key | sudo apt-key add -
109
RUN echo deb http://pkg.jenkins-ci.org/debian-stable binary/ >> /etc/apt/sources.list
@@ -18,16 +17,15 @@ RUN chmod +x /usr/local/bin/jenkins.sh
1817
USER jenkins
1918

2019
# VOLUME /var/jenkins_home - bind this in via -v if you want to make this persistent.
21-
VOLUME /var/jenkins_home
2220
ENV JENKINS_HOME /var/jenkins_home
2321

2422
# define url prefix for running jenkins behind Apache (https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache)
2523
ENV JENKINS_PREFIX /
2624

2725
# for main web interface:
28-
EXPOSE 8080
26+
EXPOSE 8080
2927

3028
# will be used by attached slave agents:
31-
EXPOSE 50000
29+
EXPOSE 50000
3230

3331
CMD ["/usr/local/bin/jenkins.sh"]

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Official Jenkins Docker image
22

3-
The Jenkins Continuous Integration and Delivery server.
3+
The Jenkins Continuous Integration and Delivery server.
44

55
This is a fully functional Jenkins server, based on the Long Term Support release
66
http://jenkins-ci.org/
@@ -15,29 +15,36 @@ http://jenkins-ci.org/
1515
docker run -p 8080:8080 jenkins
1616
```
1717

18-
This will store the workspace in /var/jenkins_home. All Jenkins data lives in there - including plugins and configuration. You will probably want to make that a persistent volume (recommended):
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):
1920

2021
```
21-
docker run --name myjenkins -p 8080:8080 -v /your/home:/var/jenkins_home jenkins
22+
docker run -p 8080:8080 -v /your/home:/var/jenkins_home jenkins
2223
```
2324

24-
The volume for the "myjenkins" named container will then be persistent.
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).
2527

26-
You can also bind mount in a volume from the host:
2728

28-
First, ensure that /your/home is accessible by the jenkins user in container (jenkins user - uid 102 normally - or use -u root), then:
29+
You can also use a volume container:
2930

3031
```
31-
docker run -p 8080:8080 -v /your/home:/var/jenkins_home jenkins
32+
docker run --name myjenkins -p 8080:8080 -v /var/jenkins_home jenkins
3233
```
3334

35+
Then myjenkins container has the volume (please do read about docker volume handling to find out more).
36+
3437
## Backing up data
3538

36-
If you bind mount in a volume - you can simply back up that directory (which is jenkins_home) at any time. 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.
39+
If you bind mount in a volume - you can simply back up that directory
40+
(which is jenkins_home) at any time.
41+
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.
3743

38-
If your volume is inside a container - you can use ```docker cp $ID:/var/jenkins_home``` command to extract the data.
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)
3946

40-
# Attaching build executors
47+
# Attaching build executors
4148

4249
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.
4350

@@ -46,7 +53,10 @@ You can run builds on the master (out of the box) buf if you want to attach buil
4653

4754
# Upgrading
4855

49-
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.
56+
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.
5057

58+
As always - please ensure that you know how to drive docker - especially volume handling!
5159

60+
# Questions?
5261

62+
Jump on irc.freenode.net and the #jenkins room. Ask!

init.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import hudson.model.*;
22
import jenkins.model.*;
33

4-
println "--> setting agent port for jnlp"
5-
Jenkins.instance.setSlaveAgentPort(50000)
4+
5+
Thread.start {
6+
sleep 10000
7+
println "--> setting agent port for jnlp"
8+
Jenkins.instance.setSlaveAgentPort(50000)
9+
}

0 commit comments

Comments
 (0)