Docker Community Forums

Share and learn in the Docker community.

Docker in docker volume mount doesn't work

I have the below command in my Jenkinsfile :

docker run --rm -v "${WORKSPACE}":/var/cache/de --entrypoint=/usr/local/bin/pytest ${IMAGE_NAME}:${IMAGE_VERSION} -m "not require_dss" -s -v --cov-report term --cov=app_dss_bundle --junitxml=/var/cache/de/rtest.xml tests

ls -l

I’m running inside docker slave, so it means its docker inside docker. I can’t see the rtest.xml in the WORKSPACE afterward (it works for me in my private linux docker env). I already tried to run the suggestion of -v /var/run/docker.sock:/var/run/docker.sock but it didn’t help. any other idea?

A Docker container in a Docker container uses the parent HOST’s Docker daemon and hence, any volumes that are mounted in the “docker-in-docker” case is still referenced from the HOST, and not from the Container.

Therefore, the actual path mounted from the Jenkins container “does not exist” in the HOST. Due to this, a new directory is created in the “docker-in-docker” container that is empty. Same thing applies when a directory is mounted to a new Docker container inside a Container.

So what is your suggestion? Is there any way to make this mount work?

Once again lewish95 the Let me Google that for you bot has committed plagiarism. (ref)