How to run a docker image in jenkins which is already in Docker Container

1.3k views Asked by At

I need to run my own docker image in jenkins pipeline job and my jenkins is already running in a container?

Is there any possible way to do it?

2

There are 2 answers

0
Yaron Idan On

There are a number of docker images built exactly for this purpose. Try this one for example - https://hub.docker.com/r/tehranian/dind-jenkins-slave/

0
ludenus On

Another approach is to configure jenkins slave so that child docker containers are invoked on the same docker host as jenkins slave siblings, and not inside dockerized jenkins slave.

This approach has certain limitations (e.g. when mounting folders) but avoids running nested dockers.

docker run -v /var/run/docker.sock:/var/run/docker.sock

Details are here: https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci