-
Notifications
You must be signed in to change notification settings - Fork 586
Add rootless Docker support and update documentation #1549
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
base: main
Are you sure you want to change the base?
Changes from 13 commits
f04fa56
5d1349e
f990993
462c8b9
eb3c1ff
30e6ab2
abeb35c
19776b9
cb86b23
e9402b8
cf6aaaa
b39a1a2
dd731b4
83e84ae
141dc1f
42e22c9
8f0ee60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| echo "=== Custom Rootless Docker Socket Path Test ===" | ||
|
|
||
| # Test that the custom socket path is properly configured | ||
| EXPECTED_SOCKET="/custom/docker/rootless.sock" | ||
|
|
||
| # Check if the custom socket exists and is accessible | ||
| check "custom-socket-exists" test -S "$EXPECTED_SOCKET" | ||
| check "custom-socket-readable" test -r "$EXPECTED_SOCKET" | ||
|
|
||
| # Verify Docker functionality using the custom socket | ||
| export DOCKER_HOST="unix://$EXPECTED_SOCKET" | ||
| check "docker-functional-custom" docker ps >/dev/null | ||
|
|
||
| # Verify that DOCKER_HOST is properly set by the feature | ||
| check "docker-host-env-set" [ ! -z "$DOCKER_HOST" ] | ||
|
|
||
| # Test basic Docker operations | ||
| check "docker-version" docker version --format '{{.Client.Version}}' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+' >/dev/null | ||
| check "docker-info" docker info >/dev/null | ||
|
|
||
| echo "Custom socket path: $EXPECTED_SOCKET" | ||
| echo "Docker host: $DOCKER_HOST" | ||
|
|
||
| reportResults |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| # Test script to detect Docker type | ||
|
|
||
| if [ -S "/var/run/docker.sock" ]; then | ||
| echo "Root Docker detected" | ||
| export DOCKER_HOST="unix:///var/run/docker-host.sock" | ||
| elif [ -S "/var/run/docker-rootless.sock" ]; then | ||
| echo "Rootless Docker detected" | ||
| export DOCKER_HOST="unix:///var/run/docker-rootless.sock" | ||
| else | ||
| echo "No Docker socket found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| docker --version | ||
| docker info --format '{{.SecurityOptions}}' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| echo "=== Rootless Docker Socket Configuration Test ===" | ||
|
|
||
| # Test the custom rootless socket path | ||
| EXPECTED_SOCKET="/var/run/docker-rootless.sock" | ||
|
|
||
| # Check if the configured rootless socket exists and is accessible | ||
| check "rootless-socket-exists" test -S "$EXPECTED_SOCKET" | ||
| check "rootless-socket-readable" test -r "$EXPECTED_SOCKET" | ||
|
|
||
| # Verify Docker functionality using the rootless socket | ||
| export DOCKER_HOST="unix://$EXPECTED_SOCKET" | ||
| check "docker-functional-rootless" docker ps >/dev/null | ||
|
|
||
| # Test basic Docker operations with rootless configuration | ||
| check "docker-version-rootless" docker version --format '{{.Client.Version}}' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+' >/dev/null | ||
| check "docker-info-rootless" docker info >/dev/null | ||
|
|
||
| # Demonstrate that customers can configure custom socket paths | ||
| echo "Configured rootless socket path: $EXPECTED_SOCKET" | ||
| echo "Docker host: $DOCKER_HOST" | ||
|
|
||
| reportResults |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,5 +180,65 @@ | |
| "moby": false | ||
| } | ||
| } | ||
| }, | ||
| "rootless_docker_socket": { | ||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04", | ||
| "features": { | ||
| "docker-outside-of-docker": { | ||
| "moby": false, | ||
| "socketPath": "/var/run/docker-rootless.sock" | ||
| } | ||
| }, | ||
| "mounts": [ | ||
| { | ||
| "source": "/var/run/docker.sock", | ||
| "target": "/var/run/docker-rootless.sock", | ||
| "type": "bind" | ||
| } | ||
| ], | ||
| "containerUser": "vscode" | ||
| }, | ||
| "root_docker_socket": { | ||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04", | ||
| "features": { | ||
| "docker-outside-of-docker": { | ||
| "moby": false | ||
| } | ||
| }, | ||
| "containerUser": "vscode" | ||
| }, | ||
| "custom_rootless_socket_path": { | ||
|
||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04", | ||
| "features": { | ||
| "docker-outside-of-docker": { | ||
| "moby": false, | ||
| "socketPath": "/custom/docker/rootless.sock" | ||
| } | ||
| }, | ||
| "mounts": [ | ||
| { | ||
| "source": "/var/run/docker.sock", | ||
| "target": "/custom/docker/rootless.sock", | ||
| "type": "bind" | ||
| } | ||
| ], | ||
| "containerUser": "vscode" | ||
| }, | ||
| "xdg_runtime_dir_socket": { | ||
|
||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04", | ||
| "features": { | ||
| "docker-outside-of-docker": { | ||
| "moby": false, | ||
| "socketPath": "/var/run/user-docker.sock" | ||
| } | ||
| }, | ||
| "mounts": [ | ||
| { | ||
| "source": "/var/run/docker.sock", | ||
| "target": "/var/run/user-docker.sock", | ||
| "type": "bind" | ||
| } | ||
| ], | ||
| "containerUser": "vscode" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| echo "=== XDG Runtime Directory Socket Test ===" | ||
|
|
||
| # Test XDG_RUNTIME_DIR style socket configuration | ||
| EXPECTED_SOCKET="/var/run/user-docker.sock" | ||
|
|
||
| # Check if the socket exists and is accessible | ||
| check "xdg-socket-exists" test -S "$EXPECTED_SOCKET" | ||
| check "xdg-socket-readable" test -r "$EXPECTED_SOCKET" | ||
|
|
||
| # Verify Docker functionality using the XDG-style socket | ||
| export DOCKER_HOST="unix://$EXPECTED_SOCKET" | ||
| check "docker-functional-xdg" docker ps >/dev/null | ||
|
|
||
| # Test that this works for rootless-style configurations | ||
| check "docker-version-xdg" docker version --format '{{.Client.Version}}' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+' >/dev/null | ||
|
|
||
| # Verify the socket path matches what a customer would configure | ||
| echo "XDG-style socket path: $EXPECTED_SOCKET" | ||
| echo "Docker host: $DOCKER_HOST" | ||
|
|
||
| reportResults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the relevance of this check for rootless Docker support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 @sireeshajonnalagadda Did we not need this before; if so, how? Also, since they are both very similiar, can we do: