6.3 KiB
gitea-ci-in-gvisor
Gitea Actions deployment with a gVisor-sandboxed Docker-in-Docker daemon for CI jobs. The runner talks to that daemon over a private Compose network; it does not receive a host Docker socket.
This repository mirrors the deployment layout used on the target host:
Gitea (Caddy + gitea networks)
│
├── act_runner (gitea + ci networks)
│ │ Docker API: tcp://dind:2375
│ ▼
└── dind (ci network, runtime: runsc-docker)
│ Docker daemon inside gVisor
▼
CI job containers
Container nesting
physical host
├── gitea container [host default runtime] networks: caddy, gitea
├── runner container [host default runtime] networks: gitea, ci
└── dind container [runsc-docker] network: ci
└── CI job container [runc inside gVisor] created by dind
The target host defaults to runsc, so Gitea and the runner also run under
gVisor unless the host configuration says otherwise. dind explicitly requests
the runsc-docker runtime because it runs Docker inside the sandbox.
Compose layout
networks:
caddy external
gitea bridge
ci bridge
services:
server Gitea, on caddy + gitea
dind gVisor Docker-in-Docker, on ci
runner act_runner, on gitea + ci
Persistent paths
./gitea -> /data Gitea data
./dind-data -> /var/lib/docker dind storage
./dind-runsc/resolv.conf -> /etc/resolv.conf:ro dind DNS
./runner -> /data act_runner config/state
/etc/timezone -> /etc/timezone:ro Gitea timezone
/etc/localtime -> /etc/localtime:ro Gitea timezone
The Gitea HTTP port is intentionally not published; it is expected to be
fronted by Caddy through the external caddy network. SSH is published on
host port 222.
Requirements
-
Docker with the
runsc-dockerruntime configured on the host. -
The host
daemon.jsonmust define a runtime equivalent to:{ "runtimes": { "runsc-docker": { "path": "/usr/bin/runsc", "runtimeArgs": [ "--net-raw", "--allow-packet-socket-write" ] } } } -
An external Docker network named
caddy. -
A Caddy configuration that routes the public Gitea hostname to the
giteacontainer on port 3000. -
./dind-runsc/resolv.confwith usable DNS servers.
Usage
# Create the external reverse-proxy network once.
docker network create caddy
# Build the gVisor dind image and start the stack.
docker compose up -d --build
Check the stack:
docker compose ps
docker compose logs -f dind
docker compose logs -f runner
Runner registration
./runner is mounted as /data and must contain:
config.yaml— act_runner configuration (included here)..runner— registration state, created on first registration.
If the runner has not been registered yet, provide a registration token on the
first boot. One way is to add this to the runner service temporarily:
environment:
GITEA_RUNNER_REGISTRATION_TOKEN: <token>
Then start the runner once, confirm ./runner/.runner exists, and remove the
token from the Compose environment again.
The public Gitea instance is expected at:
https://gitea.ct.cozytren.ch
Runner configuration
runner/config.yaml defines:
- capacity
1 - labels:
ubuntu-latest→node:22-bookwormgvisor→alpine:3.20docker→docker:28-cli
- runner-side Docker host:
tcp://dind:2375 - job environment:
DOCKER_HOST=tcp://127.0.0.1:2375 - job networking:
hostinside the dind sandbox
Jobs run with host networking inside the gVisor sandbox, so loopback points at
the dind daemon listening inside that sandbox. The runner itself reaches dind
through the ci network.
Example workflows are in scripts/:
scripts/workflow-gvisor.yml basic gVisor / isolation checks
scripts/workflow-docker.yml Docker CLI inside the sandbox
scripts/workflow-compose.yml a Compose stack inside the sandbox
scripts/workflow-resource.yml disk / memory / CPU stress
dind storage and overlayfs
The dind image comes from the gVisor Docker-in-gVisor example under
gvisor/images/basic/docker.
By default, start-dockerd.sh mounts a RAM-backed tmpfs at /var/lib/docker:
DOCKER_TMPFS_SIZE=5G
That is the gVisor-recommended path for Docker 29 overlayfs, but it limits image/build storage to 5 GiB.
To use the disk-backed ./dind-data volume instead, uncomment:
command: --no-overlay
The startup script then disables Docker 29's containerd snapshotter so it can fall back to a non-overlay storage path. Verify that the selected storage driver works inside your gVisor version before relying on large builds.
Networking details
dindhas no published Docker API port.runnerreachesdind:2375only over the privatecinetwork.- CI jobs reach the dind daemon at
127.0.0.1:2375because they share the dind sandbox network namespace. dindhas a customresolv.confmounted read-only. Keep it aligned with the DNS setup of the deployment host.- Docker’s embedded DNS inside nested user-defined networks can be limited
because Docker-managed iptables is disabled inside gVisor. The Compose test
uses a static IP plus
extra_hostsfor this reason.
Security model
- No host
/var/run/docker.sockis mounted into the runner or CI jobs. - The Docker daemon used by CI is itself inside a gVisor sandbox.
- The Docker API is not published on a host port; it is reachable only from the
ciCompose network. - CI job containers are created by the sandboxed dind daemon and remain inside that gVisor sandbox.
- The
dindcontainer needscap_add: ALLso Docker can operate inside the sandbox. Those capabilities are perceived inside gVisor, not granted on the host kernel. - The remaining security boundary is gVisor itself. Use a current gVisor release, a dedicated Docker host, and host firewall rules for untrusted CI.
Files
docker-compose.yml
runner/config.yaml
gvisor/images/basic/docker/Dockerfile
gvisor/images/basic/docker/start-dockerd.sh
dind-runsc/resolv.conf
scripts/workflow-*.yml