linux - Docker in Docker cannot mount volume -


i running jenkins cluster in master , slave, both running docker containers.

the host latest boot2docker vm running on macos.

to allow jenkins able perform deployment using docker, have mounted docker.sock , docker client host jenkins container :-

docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker -v $host_jenkins_data_directory/jenkins_data:/var/jenkins_home -v $host_ssh_keys_directory/.ssh/:/var/jenkins_home/.ssh/ -p 8080:8080 jenkins 

i facing issues while mounting volume docker containers run inside jenkins container. example, if need run container inside jenkins container, following :-

sudo docker run -v $jenkins_container/deploy.json:/root/deploy.json $container_repo/$container_image  

the above runs container, file "deploy.json" not mounted file, instead "directory". if mount directory volume, unable view files in resulting container.

is problem, because of file permissions due docker in docker case ?

any pointers useful !

thanks!

a docker container in docker container uses parent host's docker daemon , hence, volumes mounted in "docker-in-docker" case still referenced host, , not container.

therefore, actual path mounted jenkins container "does not exist" in host. due this, new directory created in "docker-in-docker" container empty. same thing applies when directory mounted new docker container inside container.

very basic , obvious thing missed, realized typed question.


Comments