Skip to content

Commit

Permalink
Revert "wip: fix docker socket perms"
Browse files Browse the repository at this point in the history
This reverts commit 2d88dfb.
  • Loading branch information
bpkroth committed Oct 18, 2024
1 parent 5fe9927 commit 1397ee1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
10 changes: 4 additions & 6 deletions .devcontainer/build/build-devcontainer-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ if [ ! -w /var/run/docker.sock ]; then
echo "ERROR: $USER does not have write access to /var/run/docker.sock. Please add $USER to the docker group." >&2
exit 1
fi
docker_sock=
if [ -e /var/run/docker-host.sock ]; then
docker_sock=$(readlink -f /var/run/docker-host.sock)
else
docker_sock=$(readlink -f /var/run/docker.sock)
DOCKER_GID=$(stat $STAT_FORMAT_GID_ARGS /var/run/docker.sock)
# Make this work inside a devcontainer as well.
if [ -w /var/run/docker-host.sock ]; then
DOCKER_GID=$(stat $STAT_FORMAT_GID_ARGS /var/run/docker-host.sock)
fi
DOCKER_GID=$(stat $STAT_FORMAT_GID_ARGS "$docker_sock")

export DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1}
devcontainer_cli_build_args=''
Expand Down
11 changes: 4 additions & 7 deletions .devcontainer/build/build-devcontainer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ MLOS_AUTOTUNING_IMAGE="mlos-devcontainer:latest"
# Build the helper container that has the devcontainer CLI for building the devcontainer.
NO_CACHE=${NO_CACHE:-} ./build-devcontainer-cli.sh

docker_sock=
if [ -e /var/run/docker-host.sock ]; then
docker_sock=$(readlink -f /var/run/docker-host.sock)
else
docker_sock=$(readlink -f /var/run/docker.sock)
DOCKER_GID=$(stat $STAT_FORMAT_GID_ARGS /var/run/docker.sock)
# Make this work inside a devcontainer as well.
if [ -w /var/run/docker-host.sock ]; then
DOCKER_GID=$(stat $STAT_FORMAT_GID_ARGS /var/run/docker-host.sock)
fi
DOCKER_GID=$(stat $STAT_FORMAT_GID_ARGS "$docker_sock")


# Build the devcontainer image.
rootdir="$repo_root"
Expand Down
8 changes: 3 additions & 5 deletions .devcontainer/scripts/run-devcontainer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@ container_name="$repo_name.$(stat $STAT_FORMAT_INODE_ARGS "$repo_root/")"
# Be sure to use the host workspace folder if available.
workspace_root=${LOCAL_WORKSPACE_FOLDER:-$repo_root}

docker_sock=
if [ -e /var/run/docker-host.sock ]; then
docker_sock=$(readlink -f /var/run/docker-host.sock)
docker_gid=$(stat $STAT_FORMAT_GID_ARGS /var/run/docker-host.sock)
else
docker_sock=$(readlink -f /var/run/docker.sock)
docker_gid=$(stat $STAT_FORMAT_GID_ARGS /var/run/docker.sock)
fi
DOCKER_GID=$(stat $STAT_FORMAT_GID_ARGS "$docker_sock")

set -x
mkdir -p "/tmp/$container_name/dc/shellhistory"
docker run -it --rm \
--name "$container_name" \
--user vscode \
--env USER=vscode \
--group-add $DOCKER_GID \
--group-add $docker_gid \
-v "$HOME/.azure":/dc/azure \
-v "/tmp/$container_name/dc/shellhistory:/dc/shellhistory" \
-v /var/run/docker.sock:/var/run/docker.sock \
Expand Down

0 comments on commit 1397ee1

Please sign in to comment.