Run builds on Jenkins Slave nodes through Docker

182 views
Skip to first unread message

Natale Vinto

unread,
Nov 7, 2016, 11:48:34 AM11/7/16
to Jenkins Users
Hello,

I was looking at documentation about running builds on jenkins slave through Docker and everything looks fine with Docker cloud provider and a jenkins slave image running docker on the same Jenkins host, but I didn't understood if it would be possible to run builds on Docker containers as slaves living on another physical/virtual Jenkins node, and how to get it. 

Is it possible?

Thanks

Natale

thomas....@teamaol.com

unread,
Nov 8, 2016, 4:57:45 AM11/8/16
to Jenkins Users
  • From my understanding you would build on slaves with Docker installed there (I guess you have OPS guys for that?).
  • Then you can create Docker images and/or Docker container as needed.
  • As an example you could create a container that install Java 8 and Maven 3 building then a Maven project.
  • Usually you would do a cleanup afterwards ... at least you remove the container (usually with --rm=true done automatically)
    Keep in mind that every build job whould have an own Docker container since those jobs usually run in parallel.
  • You should be able to test that build locally ... sth. like following: docker run --rm=true -v $PWD:/docker -it centos:7.2.15 /docker/build-it.sj
...when this is ... what you have been looking for ...

Natale Vinto

unread,
Nov 10, 2016, 5:42:21 AM11/10/16
to Jenkins Users
Hello,

thanks for the help. At the end it was an issue with Firewalld on the Node supposed to host jenkins slave docker containers, which prevented to launch iptables commands. It was not clear to me where Docker plugin executes command but once it connect to Docker REST API, it can launch command on the machine that host the docker engine exposing rest API.

To share my experience on that, what I did is:

- Disable firewalld and install iptables-service on the CentOS/RHEL machine I was working on
- Configure Docker plugin to reach the physical/virtual node with Docker installed that exposes rest API (-H tcp://0.0.0.0:4243 )
- In the Docker template, use a docker image suitable for maven build, such as bibinwilson/jenkins-slave:maven
- Label the slave in order to use it in the Build

in this way everything is fine with several docker jenkins slave :)

Thanks

Natale
Reply all
Reply to author
Forward
0 new messages