using docker-compose on a kubernetes instance with jenkins - mounting empty volumes

5/6/2018

I have a Jenkins instance setup using Googles Jenkins on Kubernetes solution. I have not changed any of the settings of the Kubernetes Pod.

When I trigger a new job I am successfully able to get everything up and running until the point of my tests.

My tests use docker-compose. First I make sure to install docker (1.5-1+b1) and docker-compose (1.8.0-2) on the instance (I know I can optimize this by using an image that already includes these, but I am still just in proof-of-concept).

When I run the docker-compose up command everything works and the services start their initialization scripts. However, the mounts are empty. I have verified that the files exist on the Jenkins slave, and the mount is created inside the docker service when I run docker-compose, however they are empty.

Some information:

In order to get around file permissions I am using /tmp as the Jenkins Workspace. I am using SCM to pull my files (successfully) and in the docker-compose file I specify version: '2' and the mount paths with absolute paths. The volume section of the service that fails looks like this:

volumes:
 - /tmp/automation:/opt/automation

I changed the command that is run in the service to ls /opt/automation and the result is an empty directory.

What am I missing? I just want to mount a directory into my docker-compose service. This works perfectly from Windows, Ubuntu, and Centos devices. Why won't it work using the Kubernetes instance?

-- Inbar Rose
docker
docker-compose
google-cloud-platform
jenkins
kubernetes

1 Answer

5/6/2018

I found the reason it fails here:

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 it seems like it will be impossible to mount something from the outer docker into the inner docker. And another solution must be found.

-- Inbar Rose
Source: StackOverflow