34 lines
1.0 KiB
Bash
34 lines
1.0 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Runs inside the runner container (not inside gVisor). It asks the runner's
|
|
# private dockerd to launch a second, gVisor-sandboxed Docker daemon and shares
|
|
# only that daemon's socket volume with CI jobs.
|
|
|
|
docker volume create gvisor-dind-data >/dev/null
|
|
|
|
docker rm -f gvisor-dind >/dev/null 2>&1 || true
|
|
docker run -d \
|
|
--name gvisor-dind \
|
|
--restart unless-stopped \
|
|
--runtime=runsc-net \
|
|
--privileged \
|
|
-p 127.0.0.1:2375:2375 \
|
|
-v gvisor-dind-data:/var/lib/docker \
|
|
-v /opt/gvisor-dind/start-dind.sh:/opt/gvisor-dind/start-dind.sh:ro \
|
|
--entrypoint /opt/gvisor-dind/start-dind.sh \
|
|
docker:28-dind >/dev/null
|
|
|
|
echo "Waiting for the sandboxed Docker daemon..."
|
|
for _ in $(seq 1 120); do
|
|
if docker exec gvisor-dind docker info >/dev/null 2>&1; then
|
|
echo "Sandboxed Docker daemon is ready."
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "Sandboxed Docker daemon did not become ready" >&2
|
|
docker logs --tail 120 gvisor-dind >&2 || true
|
|
exit 1
|