Mounted Docker volume has different ownership when using Travis

The repository is for static site built from Jupyter notebooks. The notebooks are converted using build/build.py which, for each post, builds a Docker image, starts a corresponding container with the post notebook directory mounted, and uses nbconvert to convert the notebook to Markdown. One step of nbconvert’s conversion involves creating a supporting file directory. This fails on Travis due to a permission issue.

In attempting to debug this problem, I found that the ownership and permissions of the repo are the same on my local machine and Travis (with my username switched for travis) before running Docker. Despite this, inside the mounted volume of the Docker container, the ownerships are different.

Very confused.

Hello @Northskool,

This should involve the creation of the new files inside the Docker container to be owned by DOCKER_USER_ID.

If you are able to guess that mounting points will exist, you could also pre-create them so the ownership of the files inside is also correct:

docker run -v /path/on/host:/path/in/container ...

If you set the permissions of your local path (/path/on/host) as 777, that will also be propagated to the mounting point: no permission error will be thrown regardless of the user that container uses to create those files.

After that, you’ll be free to restore permissions, if needed.

1 Like

This was it @Montana, thank you.

Glad I could help @Northskool.

1 Like