Repository navigation
fix(docker-outside-of-docker): check DOCKER_GID on container start #1749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Abdurrahmaan Iqbal (abdurriq)
merged 12 commits into
devcontainers:main
from
varmiral:main
Nov 18, 2026
+119
−6
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f67c6d1
[docker-outside-of-docker] - The socat branch no longer executes afte…
varmiral 9ec301c
Merge branch 'main' into main
v-Kaniska244 8d08c5c
fixed a syntax error
varmiral 2e4ae99
Update docker-outside-of-docker version to 1.10.2
varmiral 64ca56e
Merge branch 'main' into main
v-Kaniska244 e91018e
Merge branch 'main' into main
v-Kaniska244 780a750
Enhance socket GID check for Docker installation
varmiral e9ba8a2
Merge branch 'main' into main
v-Kaniska244 4052462
Merge branch 'devcontainers:main' into main
varmiral fa70b13
Add docker_init_gid test for docker-outside-of-docker
varmiral 77f53ae
Enhance socket check for non-root Docker setup
varmiral d86a551
Update docker-outside-of-docker version to 1.10.3
varmiral File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| test_gid_case() ( | ||
| set -e | ||
|
|
||
| local scenario="$1" | ||
| export GID_TEST_DIR | ||
| GID_TEST_DIR="$(mktemp -d)" | ||
| trap 'rm -rf "${GID_TEST_DIR}"' EXIT | ||
|
|
||
| echo 2000 > "${GID_TEST_DIR}/docker-gid" | ||
| echo 100 > "${GID_TEST_DIR}/socket-gid" | ||
| touch "${GID_TEST_DIR}/source.sock" "${GID_TEST_DIR}/groups" | ||
| ln -s "${GID_TEST_DIR}/source.sock" "${GID_TEST_DIR}/target.sock" | ||
|
|
||
| sed -e "s|/var/run/docker-host.sock|${GID_TEST_DIR}/source.sock|g" \ | ||
| -e "s|/var/run/docker.sock|${GID_TEST_DIR}/target.sock|g" \ | ||
| -e "s|/tmp/vscr-docker-from-docker|${GID_TEST_DIR}/proxy|g" \ | ||
| /usr/local/share/docker-init.sh > "${GID_TEST_DIR}/docker-init.sh" | ||
|
|
||
| getent() { | ||
| if [ "$1" != group ]; then | ||
| return 1 | ||
| fi | ||
| if [ "$2" = docker ] || [ "$2" = "$(cat "${GID_TEST_DIR}/docker-gid")" ]; then | ||
| echo "docker:x:$(cat "${GID_TEST_DIR}/docker-gid"):vscode" | ||
| else | ||
| awk -F: -v gid="$2" '$3 == gid { print; found = 1 } END { exit !found }' "${GID_TEST_DIR}/groups" | ||
| fi | ||
| } | ||
|
|
||
| stat() { | ||
| [ "$1" = -c ] && [ "$2" = '%g' ] && [ "$3" = "${GID_TEST_DIR}/source.sock" ] | ||
| cat "${GID_TEST_DIR}/socket-gid" | ||
| } | ||
|
|
||
| groupmod() { | ||
| [ "$1" = --gid ] && [ "$3" = docker ] | ||
| echo "$2" > "${GID_TEST_DIR}/docker-gid" | ||
| echo "$*" > "${GID_TEST_DIR}/groupmod" | ||
| } | ||
|
|
||
| id() { | ||
| [ "$1" = -u ] | ||
| echo 0 | ||
| } | ||
|
|
||
| socat() { | ||
| return 0 | ||
| } | ||
|
|
||
| export -f getent stat groupmod id socat | ||
|
|
||
| case "${scenario}" in | ||
| matching|stale-target) | ||
| echo 100 > "${GID_TEST_DIR}/docker-gid" | ||
| if [ "${scenario}" = stale-target ]; then | ||
| rm "${GID_TEST_DIR}/target.sock" | ||
| touch "${GID_TEST_DIR}/target.sock" | ||
| fi | ||
| ;; | ||
| prefix) | ||
| echo 'other:x:1000:' > "${GID_TEST_DIR}/groups" | ||
| ;; | ||
| collision) | ||
| echo 'other:x:100:' > "${GID_TEST_DIR}/groups" | ||
| ;; | ||
| *) return 1 ;; | ||
| esac | ||
|
|
||
| bash "${GID_TEST_DIR}/docker-init.sh" true || return 1 | ||
|
|
||
| case "${scenario}" in | ||
| matching) | ||
| [ -L "${GID_TEST_DIR}/target.sock" ] && | ||
| [ "$(readlink "${GID_TEST_DIR}/target.sock")" = "${GID_TEST_DIR}/source.sock" ] && | ||
| [ ! -e "${GID_TEST_DIR}/proxy.pid" ] && | ||
| [ ! -e "${GID_TEST_DIR}/groupmod" ] && | ||
| grep -q 'Docker group matches socket GID 100, nothing to do' "${GID_TEST_DIR}/proxy.log" | ||
| ;; | ||
| prefix) | ||
| [ "$(cat "${GID_TEST_DIR}/docker-gid")" = 100 ] && | ||
| grep -qx -- '--gid 100 docker' "${GID_TEST_DIR}/groupmod" && | ||
| [ -L "${GID_TEST_DIR}/target.sock" ] && | ||
| [ ! -e "${GID_TEST_DIR}/proxy.pid" ] | ||
| ;; | ||
| collision|stale-target) | ||
| [ ! -L "${GID_TEST_DIR}/target.sock" ] && | ||
| [ -s "${GID_TEST_DIR}/proxy.pid" ] && | ||
| [ ! -e "${GID_TEST_DIR}/groupmod" ] && | ||
| grep -q 'Enabling socket proxy.' "${GID_TEST_DIR}/proxy.log" | ||
| ;; | ||
| esac | ||
| ) | ||
|
|
||
| check "runtime-matching-gid-preserves-symlink-without-proxy" test_gid_case matching | ||
|
v-Kaniska244 marked this conversation as resolved.
Resolved
|
||
| check "prefix-only-gid-match-updates-docker-group-without-proxy" test_gid_case prefix | ||
| check "exact-gid-collision-enables-proxy" test_gid_case collision | ||
| check "matching-gid-with-stale-target-enables-proxy" test_gid_case stale-target | ||
|
|
||
| reportResults | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.