Project

General

Profile

Using Docker with Jenkins » History » Version 2

« Previous - Version 2/7 (diff) - Next » - Current version
Seth Graham, 03/15/2016 04:13 PM


Using Docker with Jenkins

The build node buildservice008 has been installed with SL7.2 and is running Docker, allowing the specification of builds that run inside a Docker Container. This feature is provided by the "docker-custom-build-environment" plugin, which is documented here:

https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Custom+Build+Environment+Plugin

It allows the creation of a temporary Linux host, using any Linux distribution, and running a build job inside of it.

This offering is currently in a testing/provisional phase and comes with some limitations.

LIMITATIONS

a) Containers are unsupported. You are in effect consenting to be a system admin, and will need to do whatever work the container requires to be able to run builds: install packages, configure software, and manage directory structures.

b) There is no shell access to the containers. Administration tasks will need to be done within the DOCKERFILE or by the build itself.

c) You will need to create a "jenkins" user inside your container. UID/GID should be 500. Without this, your job will probably crash.

d) All containers are firewalled. No inbound connections are permitted. Outbound connections are permitted.

e) No NFS mounts (including bluearc). As the containers don't exist as registered linux hosts, it's not possible to export NFS shares to them. Builds will have to pull in everything they need via ssh or wget.

f) CVMFS is not offered. It may be possible to configure CVMFS inside the container but you will need to configure it yourself.

g) Production of artifacts does not seem to work. This could be my fault due to ignorance or a limitation of the docker interface, there will probably be growing pains to sort through with this.

h) Containers are not guaranteed to be persistent. 1TB of storage has been allocated to containers so they won't be deleted constantly, but your builds will not be able to assume a container it used previously (and the data inside it) still exists and it may have to re-create it.

USAGE

a) Inside the Jenkins web interface on buildmaster, you configure a build to use docker inside the project's configuration page. A number of new options have appeared in the configuration, but only a few are required to actually get things going:

1) The "Docker Host URI" field must be set to "tcp://131.225.67.229:2375" so Jenkins can communicate with docker on buildservice008.

2) "Volumes" must have an entry to map buildservice008's /tmp to the container's /tmp. Without this, Jenkins won't be able to run the build script.

3) You will also want to restrict where the build can run. I have added the "docker" tag to buildservice008 so if you use that, builds that use docker will always go to that host.

b) DOCKERFILES are the most effective way to customize a container. There is some documentation for these configuration files found here:

https://docs.docker.com/engine/reference/builder/

Add this file to your git repo, and in the "Docker image to use" section of your project configuration, specify the name of the file. When the build is run this dockerfile will be parsed and executed.