Skip to content

Commit d2ee40f

Browse files
fix(boot): Don't change group ownership of docker socket
This is a better fix for issue #804. Instead of changing the gid of the docker socket to that of the deis group in the container, which affects access to the docker socket by existing users on the host, we now either add the deis user to an existing group in the container with the same gid or create a new "docker" group with the same gid as the socket if no existing group has that gid.
1 parent 3b6d094 commit d2ee40f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

rootfs/bin/boot

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ python --version
1616
mkdir -p /app/data/logs
1717
chmod -R 777 /app/data/logs
1818

19-
# HACK(bacongobbler): explicitly add the docker socket to the deis group
20-
chgrp deis /var/run/docker.sock
21-
22-
# allow deis user group permission to Docker socket
23-
groupadd -g "$(stat -c "%g" /var/run/docker.sock)" docker || true
24-
usermod -a -G docker deis || true
19+
# modify deis user groups to grant access to Docker socket
20+
DOCKER_SOCKET_GID=$(stat -c "%g" /var/run/docker.sock)
21+
DOCKER_SOCKET_GROUP=$(getent group "$DOCKER_SOCKET_GID" | cut -d : -f 1 || :)
22+
if [[ -z "$DOCKER_SOCKET_GROUP" ]]; then
23+
DOCKER_SOCKET_GROUP=docker
24+
groupadd -g "$DOCKER_SOCKET_GID" "$DOCKER_SOCKET_GROUP"
25+
fi
26+
if [[ "$DOCKER_SOCKET_GROUP" != "deis" ]]; then
27+
usermod -a -G "$DOCKER_SOCKET_GROUP" deis
28+
fi
2529

2630
echo ""
2731
echo "Django checks:"

0 commit comments

Comments
 (0)