The area51/jenkins-slave image contains a current Java build (it extends the area51/java:serverjre-8 image) suitable to be used as a Jenkins slave.


To run the slave you need to launch it, get it's IP address then configure jenkins to use it:

# docker run --name javaSlave area51/jenkins-slave
# docker inspect --format '{{ .NetworkSettings.IPAddress }}' jenkins-slave

Here's an example with:

  • Static IPv6 address set
  • Uses a preconfigured docker bridge network called jenkinsNet
  • Jenkins password to secret
  • Maven will use a private Nexus 3 mirror on mymirror.example
  • Will be able to deploy to maven using the user deployment and password secret
# docker run -d \
       --restart=always \
       --name javaSlave \
       --hostname javaSlave \
       --net=jenkinsNet \
       --ip6=2001:DB8:1234:5678::2 \
       -e JENKINS_PASSWORD=secret \
       -e MAVEN_MIRROR=http://mymirror.example/repository/maven-public \
       -e MAVEN_SNAPSHOT_USER=deployment \
       -e MAVEN_SNAPSHOT_PASSWORD=secret \

You would then configure it in Jenkins with [2001:DB8:1234:5678::2] as the ip address, jenkins as the ssh user and secret as the password.

Slave configuration

Then in jenkins, create a new ssh slave and enter the following details:

NameJavaYour name for this slave
DescriptionOptional description for this slave
# of executors4The number of job executors you want to run in this slave
Remote root directory/opt/jenkinsThe location to store the jobs whilst running. /opt/jenkins is configured in this container for you
LabelsjavaLabels for fixing specific jobs to this slave. You can choose what you want here, this is a suggestion.
UsageHow much you want jenkins to use it. Usually the default Use this node as much as possible is fine here.
Launch methodLaunch via sshWe want ssh here
You should now see:
Host172.17.0.5The IP address from above. If you have made it static (advisable) then use that. If it's an IPv6 address then you need to put [ ] around the address
CredentialsSelect add and create a new entry. Unless you've changed it (see below) the user is jenkins and the password jenkins
Click advanced to show next fields then:
JavaPath/opt/jdk/bin/javaThe path to the installed java binary within the container

Environment Variables

You can configure the following environment variables:

JENKINS_PASSWORDYou can set the password for the jenkins user with this variable. If you don't it defaults to jenkins

e.g. --env JENKINS_PASSWORD=beeblebrox

MAVEN_MIRRORBy default maven will use just the maven central repository. If you run your own local repository (i.e. Nexus or our area51/nexus image) then you can set this to the base url path to that mirror

e.g. --env MAVEN_MIRROR=http://mymirror.example/repository/maven-public



Username and Password to use when deploying release artifacts to your repository.
MAVEN_RELEASE_IDOnly valid if both MAVEN_RELEASE_USER & MAVEN_RELEASE_PASSWORD are defined this sets the id within settings.xml. If it's not defined then it defaults to releases


Username and Password to use when deploying snapshot artifacts to your repository.
MAVEN_SNAPSHOT_IDOnly valid if both MAVEN_SNAPSHOT_USER & MAVEN_SNAPSHOT_PASSWORD are defined this sets the id within settings.xml. If it's not defined then it defaults to snapshots
NO_SSHIf set to any value other than then this disables the built in sshd daemon but you must then provide a command to run instead otherwise the container will not start.