diff --git a/setup/scripts/l3d b/setup/scripts/l3d
index fd72a51790097511fec234bb2710c51f6b33395a..873a62dffd3ad0b0ab17252fd3888152eb5536d5 100755
--- a/setup/scripts/l3d
+++ b/setup/scripts/l3d
@@ -19,6 +19,7 @@ case "${L3DHOSTOS}" in
         SCRIPTPATH="$(dirname "$(greadlink -f "$0")")"
         L3DDOCKERHOST="$(dirname "$(greadlink -f "/var/run/docker.sock")")/docker.sock"
       fi
+      GROUPID=$(cut -d: -f3 < <(getent group docker))
       # Write a fake passwd file which will later be mounted into containers.
       echo "${USERNAME}:x:${USERID}:${GROUPID}:${USERNAME},,,:/home/${USERNAME}:${L3DSHELL}" >${HOME}/.passwd
       # This variable is used to access the ssh agent on MacOS.