Description
We should provide the same experience on Mac as on Linux. Currently most of dojo images won't work because of fix-uid-gid scripts trying to work around the mapping.
This is caused by osx driver trying to be smart about ownership of the mounted volumes.
osxfs docker driver behaviour
Basically the current user in the container always owns the mounted volume.
This snippet illustrates the problem:
Tomaszs-MacBook-Pro:code tomzo$ mkdir sandbox
Tomaszs-MacBook-Pro:code tomzo$ cd sandbox/
Tomaszs-MacBook-Pro:sandbox tomzo$ touch example.txt
Tomaszs-MacBook-Pro:sandbox tomzo$ docker run -ti -v $(pwd):/test openjdk:8u212 bash
root@ab58926a5f07:/# ls /test -la
total 4
drwxr-xr-x 3 root root 96 Sep 12 15:10 .
drwxr-xr-x 1 root root 4096 Sep 12 15:10 ..
-rw-r--r-- 1 root root 0 Sep 12 15:10 example.txt
root@ab58926a5f07:/# useradd dojo
root@ab58926a5f07:/# su dojo
$ ls -la /test
total 4
drwxr-xr-x 3 dojo dojo 96 Sep 12 15:10 .
drwxr-xr-x 1 root root 4096 Sep 12 15:10 ..
-rw-r--r-- 1 dojo dojo 0 Sep 12 15:10 example.txt
$
More detailed explanation - https://stackoverflow.com/questions/43097341/docker-on-macosx-does-not-translate-file-ownership-correctly-in-volumes
Current problem
Dojo by design has to ensure that /home/dojo
and /dojo/work
is owned by the current user.
Since /dojo/work
is a mount, on a Mac, this will be owned by current user automagically.
So there is only /home/dojo
to take care of. Currently, as part of entrypoint setup, fix-uid-gid scripts (running as root) would read uid/gid of the /dojo/work
(getting 0/0), then create and chown files in /home/dojo
. This results in home files owned by the root.
Solutions?
We need a way to handle this, ideally without a big IF Linux/Mac then
.