Skip to content

Commit b984703

Browse files
author
Julien Neuhart
committed
fixing issue with NTFS on macOS
1 parent a4f0efe commit b984703

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

utils/docker-entrypoint-as-root.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,28 @@ if [[ "$DOCKER_USER" == "" ]]; then
1616
chmod 700 testing_file_system_rights.foo
1717
su docker -c "touch testing_file_system_rights.foo/somefile > /dev/null 2>&1"
1818
HAS_CONSISTENT_RIGHTS=$?
19-
rm -rf testing_file_system_rights.foo
20-
set -e
2119

2220
if [[ "$HAS_CONSISTENT_RIGHTS" != "0" ]]; then
2321
# If not specified, the DOCKER_USER is the owner of the current working directory (heuristic!)
2422
DOCKER_USER=`ls -dl $(pwd) | cut -d " " -f 3`
2523
else
26-
# we are on a Mac or Windows... who cares about permissions?
27-
# So for Windows and MacOSX, we should force the user used to be Docker.
28-
DOCKER_USER=docker
24+
# we are on a Mac or Windows,
25+
# Most of the cases, we don't care about the rights (they are not respected)
26+
FILE_OWNER=`ls -dl testing_file_system_rights.foo/somefile | cut -d " " -f 3`
27+
if [[ "$FILE_OWNER" == "root" ]]; then
28+
# if the created user belongs to root, we are likely on a Windows host.
29+
# all files will belong to root, but it does not matter as everybody can write/delete those (0777 access rights)
30+
DOCKER_USER=docker
31+
else
32+
# In case of a NFS mount (common on MacOS), the created files will belong to the NFS user.
33+
# Apache should therefore have the ID of this user.
34+
DOCKER_USER=$FILE_OWNER
35+
fi
2936
fi
3037

38+
rm -rf testing_file_system_rights.foo
39+
set -e
40+
3141
unset HAS_CONSISTENT_RIGHTS
3242
fi
3343

@@ -70,5 +80,5 @@ if [[ "$@" == "apache2-foreground" ]]; then
7080
/usr/local/bin/apache-expose-envvars.sh;
7181
exec "$@";
7282
else
73-
exec "sudo" "-E" "-u" "#$DOCKER_USER_ID" "$@";
83+
exec "sudo" "-E" "-H" "-u" "#$DOCKER_USER_ID" "$@";
7484
fi

0 commit comments

Comments
 (0)