Mounted Docker volume has different permissions when using Travis

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. The ownership is still different.

drwxrwxr-x 2   2000  2000  4096 Dec 10 19:58 .
drwsrwsr-x 1 solarultima users  4096 Nov  8 16:37 ..
-rw-rw-r-- 1   2000  2000   101 Dec 10 19:58 Dockerfile
-rw-rw-r-- 1   2000  2000 35271 Dec 10 19:58 post.ipynb

Both my local machine and Travis are running Ubuntu 20.04, so really not sure where problem is stem from.

Try running Docker again with this command, so the uid outside the container is propagated inside:

docker run -u $(id -u)

This should involve the creation of the new files inside the docker to be owned by "solarultima" .

If you are able to guess that mounting points will exist in a particular container, you could also pre-create them so the ownership of the files inside are also correct, to avoid this issue.

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

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

2 Likes

this worked beautifully! thank you @Montana

That’s great to hear @SolarUltima.

If you need anymore help on anything else, don’t hesitate to ask.

1 Like