Public | Automated Build

Last pushed: 2 months ago
Short Description
A Jenkins master that makes it easy to run slaves in containers
Full Description

Jenkins master/slave with Docker

jenkins-in-docker a.k.a jaydp17/jenkins-master sets up a container running Jenkins master that can use the host docker engine to create/connect to Jenkins slaves running as containers.

It is built on top of the original Jenkins image, thus whatever is possible with it is also possible with this image.

Usage

To run it:

$ docker run -d -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/tmp/docker.sock:ro --privileged jaydp17/jenkins-master

Or if you prefer docker-compose:

jenkins-master:
  image: jaydp17/jenkins-master
  privileged: true
  ports:
    - "8080:8080"
    - "50000:50000"
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock:ro

As with the base Jenkins image it stores 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)

Example:

$ docker run -d -p 8080:8080 -p 50000:50000 -v /your/home:/var/jenkins_home -v /var/run/docker.sock:/tmp/docker.sock:ro --privileged jaydp17/jenkins-master

Example using docker-compose

jenkins-master:
  image: jaydp17/jenkins-master
  privileged: true
  ports:
    - "8080:8080"
    - "50000:50000"
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock:ro
    - /your/home:/var/jenkins_home

This will store the jenkins data in /your/home on the host.

How to configure Jenkins to use a Docker image as slave?

Refer to Docker in Jenkins

Troubleshooting

GitHub private repo access

Make sure you have ~/.ssh/id_rsa & ~/.ssh/id_rsa.pub in $JENKINS_HOME (i.e. /var/jenkins_home/).
Now ssh into the container and run

# test if the connection is establesed
$ ssh -T git@github.com

If the above works perfectly, your jenkins instance should be able to connect to your private repo on Github

Docker Pull Command
Owner
jaydp17
Source Repository