Skip to content

Commit

Permalink
prefer parsing ls vs. stat when looking up docker group id
Browse files Browse the repository at this point in the history
  • Loading branch information
briceburg committed Oct 31, 2016
1 parent 850bfd5 commit 807c0e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RELEASE_TAG ?= $(shell git rev-parse --abbrev-ref HEAD)
RELEASE_SHA ?= $(shell git rev-parse --short HEAD)

DOCKER_SOCKET ?= /var/run/docker.sock
DOCKER_GROUP_ID ?= $(shell if [[ "$$OSTYPE" == darwin* ]] || [[ "$$OSTYPE" == macos* ]]; then stat -f '%Dg' $(DOCKER_SOCKET) ; else stat -c '%g' $(DOCKER_SOCKET) ; fi)
DOCKER_GROUP_ID ?= $(shell ls -ln $(DOCKER_SOCKET) | awk '{print $$4}')

# for docker-for-mac, we also add group-id of 50 ("authedusers") as moby seems to auto bind-mount /var/run/docker.sock w/ this ownership
# @TODO investigate and remove this docker-for-mac kludge
Expand Down
13 changes: 8 additions & 5 deletions lib.d/v1-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ v1-runtime(){
DEX_WINDOW_FLAGS=${DEX_WINDOW_FLAGS:-"-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY"}

[ -z "$__api" ] && \
{ "$__image did not specify an org.dockerland.dex.api label!" ; exit 1 ; }
{ echo "$__image did not specify an org.dockerland.dex.api label!" ; exit 1 ; }

# if home is not an absolute path, make relative to $DEX_HOME/homes/
[ "${DEX_DOCKER_HOME:0:1}" != '/' ] && \
Expand Down Expand Up @@ -159,10 +159,13 @@ v1-runtime(){

# map host docker socket and passthru docker vars
case $(echo "$__host_docker" | awk '{print tolower($0)}') in rw|ro)
docker_socket=/var/run/docker.sock
docker_group=$(if [[ "$OSTYPE" == darwin* ]] || [[ "$OSTYPE" == macos* ]]; then stat -f '%Dg' $docker_socket ; else stat -c '%g' $docker_socket ; fi)
__docker_volumes+=" $docker_socket:/var/run/docker.sock:$__host_docker $DOCKER_CERT_PATH $MACHINE_STORAGE_PATH"
__docker_flags+=" --group-add=$docker_group"
__docker_socket=${DOCKER_SOCKET:-/var/run/docker.sock}
[ -S $__docker_socket ] || {
echo "image requests docker, but $__docker_socket is not a valid socket"
exit 1
}
__docker_volumes+=" $__docker_socket:/var/run/docker.sock:$__host_docker $DOCKER_CERT_PATH $MACHINE_STORAGE_PATH"
__docker_flags+=" --group-add=$(ls -ln $__docker_socket | awk '{print $4}')"
__docker_envars+=" DOCKER_* MACHINE_STORAGE_PATH"
esac

Expand Down

0 comments on commit 807c0e6

Please sign in to comment.