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:
gitea 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.
The Compose file passes GITEA_RUNNER_REGISTRATION_TOKEN into the runner
container. On first boot, put the token in .env:
cp .env.example .env
# edit GITEA_RUNNER_REGISTRATION_TOKEN
docker compose up -d runner
Then confirm registration:
docker compose logs -f runner
# look for: Runner registered successfully
ls -l runner/.runner
Remove the token from .env after .runner exists if you prefer. If a stale
or invalid ./runner/.runner exists, remove it before retrying:
rm -f runner/.runner
docker compose up -d --force-recreate runner
If the public URL is not reachable from inside the runner container, use the internal Gitea address instead:
GITEA_INSTANCE_URL: http://gitea:3000
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.
The default Compose configuration starts dind with:
command: --no-overlay
This skips the RAM-backed tmpfs at /var/lib/docker and uses the disk-backed
./dind-data volume instead, so image/build storage is not capped at a fixed
tmpfs size. The startup script also disables Docker 29's containerd snapshotter
for this mode.
If you prefer a bounded RAM-backed store, remove command: --no-overlay and set
DOCKER_TMPFS_SIZE explicitly:
environment:
DOCKER_TMPFS_SIZE: 5G
Performance (local test)
Short microbenchmarks with the disk-backed dind setup (--no-overlay, Docker
29.9.3, overlay2). The gVisor column used the same gVisor runtime flags as
runsc-docker; the host used for testing only exposes an inner gVisor runtime,
so this is an approximation of the target host.
| Workload | dind under runc | dind under gVisor |
|---|---|---|
| 2 GiB write | 2.7 GB/s | 2.4 GB/s |
| 2 GiB read | 18.2 GB/s | 13.6 GB/s |
| 2 GiB memory touch | 1.51 s | 1.94 s |
| BusyBox awk 10M loop | 5.22 s | 5.23 s |
Storage was the full disk-backed volume, not a 5 GiB tmpfs. Nested image builds and outbound networking worked in both runs.
These are short microbenchmarks; benchmark actual CI images for planning.
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