how to share volume between Docker in Docker on the same host

10/5/2020

I am running a Jenkins cluster where in the Master and Slave, both are running as a Docker containers, managed by K8s. So I run a job from Jenkins, a pod gets created which in turn creates a container and the Job runs.

To allow Jenkins to be able to spawn inner container from the build agent container, I have mounted the docker.sock from the host to the Jenkins Pod templated: k8s volume

For certain jobs we need to spawn another container inside the build agent container, here lies the problem, from the outer container (build agent) we would have cloned the git repo where few files are needed for the inner container (spawned container), we cannot copy them as Docker container uses the parent HOST's Docker daemon, how can i mount the volume from outer container to inner container ? Container and pods names are dynamic. Is there any workaround, any help will be highly appreciated.

-- Sanjay M. P.
docker
jenkins
kubernetes

0 Answers