Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: running docker commands on a docker slave

I'm using the Kubernetes Jenkins plugin to orchestrate jenkins slaves

I want to run all the jobs in Docker (build docker images and execute tests/builds in docker).

example jenkins job:

docker run -e NEXUS_USERNAME=${NEXUS_USERNAME} -e NEXUS_PASSWORD=${NEXUS_PASSWORD} common-dropwizard:latest mvn deploy

I am using the jenkinsci/jnlp-slave from here: https://hub.docker.com/r/jenkinsci/jnlp-slave/

Unfortunately, the slave image doesn't appear to support running docker. My question is what is the best approach to accomplish this?

thanks

like image 334
phil swenson Avatar asked Jul 21 '16 17:07

phil swenson


1 Answers

You need to install docker client and mount the docker socket so you can access the Docker host. Then you can interact with that Docker host

https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ https://github.com/jenkinsci/docker-workflow-plugin/tree/master/demo

like image 83
csanchez Avatar answered Nov 06 '22 23:11

csanchez