|
| 1 | +# Local Container Provider |
| 2 | + |
| 3 | +Read when: |
| 4 | + |
| 5 | +- choosing `provider: local-container`, `provider: docker`, or `provider: container`; |
| 6 | +- using Docker Desktop, OrbStack, Colima, Lima, or another Docker-compatible local runtime; |
| 7 | +- changing `internal/providers/localcontainer`. |
| 8 | + |
| 9 | +Local Container is an SSH lease provider for Linux containers on the local |
| 10 | +machine. Crabbox uses the configured Docker-compatible CLI to start a labeled |
| 11 | +container, publish its SSH port on loopback, syncs the current checkout into the |
| 12 | +container over SSH, runs the command, and removes the container on stop. |
| 13 | + |
| 14 | +## When To Use |
| 15 | + |
| 16 | +Use Local Container when: |
| 17 | + |
| 18 | +- you want a zero-cloud Linux smoke path; |
| 19 | +- the local Docker-compatible runtime is already warm; |
| 20 | +- you want a local visible desktop, browser, screenshot, or input smoke before |
| 21 | + spending cloud capacity; |
| 22 | +- you want the same Crabbox sync, logs, artifacts, scripts, and `ssh` workflow |
| 23 | + before moving to remote capacity. |
| 24 | + |
| 25 | +Use AWS, Azure, Google Cloud, Hetzner, Proxmox, or another remote provider when |
| 26 | +you need stronger host separation, larger capacity, cross-OS coverage, |
| 27 | +coordinator-backed portal desktops, shared team infrastructure, or |
| 28 | +provider-owned cleanup. |
| 29 | + |
| 30 | +## Quick Start |
| 31 | + |
| 32 | +```sh |
| 33 | +docker info |
| 34 | +crabbox run --provider local-container -- pnpm test |
| 35 | +crabbox warmup --provider docker --slug local-smoke |
| 36 | +crabbox run --provider docker --id local-smoke -- pnpm test:changed |
| 37 | +crabbox ssh --provider docker --id local-smoke |
| 38 | +crabbox stop --provider docker local-smoke |
| 39 | +``` |
| 40 | + |
| 41 | +Desktop/browser smoke: |
| 42 | + |
| 43 | +```sh |
| 44 | +crabbox warmup --provider docker --desktop --browser --slug local-ui |
| 45 | +crabbox desktop doctor --provider docker --id local-ui |
| 46 | +crabbox screenshot --provider docker --id local-ui --output desktop.png |
| 47 | +crabbox desktop click --provider docker --id local-ui --x 120 --y 120 |
| 48 | +crabbox webvnc --provider docker --id local-ui |
| 49 | +``` |
| 50 | + |
| 51 | +`docker` is an alias for `local-container`. The provider talks only to the |
| 52 | +Docker-compatible CLI and daemon; it does not use Docker Desktop-specific APIs. |
| 53 | +OrbStack works when it is the active `docker` context. |
| 54 | + |
| 55 | +## Config |
| 56 | + |
| 57 | +```yaml |
| 58 | +provider: local-container |
| 59 | +localContainer: |
| 60 | + runtime: docker |
| 61 | + image: debian:bookworm |
| 62 | + user: crabbox |
| 63 | + workRoot: /work/crabbox |
| 64 | + cpus: 0 |
| 65 | + memory: "" |
| 66 | + network: bridge |
| 67 | +``` |
| 68 | +
|
| 69 | +Provider flags: |
| 70 | +
|
| 71 | +```text |
| 72 | +--local-container-runtime <path-or-name> |
| 73 | +--local-container-image <image> |
| 74 | +--local-container-user <user> |
| 75 | +--local-container-work-root <path> |
| 76 | +--local-container-cpus <n> |
| 77 | +--local-container-memory <size> |
| 78 | +--local-container-network <network> |
| 79 | +``` |
| 80 | + |
| 81 | +Environment overrides: |
| 82 | + |
| 83 | +```text |
| 84 | +CRABBOX_LOCAL_CONTAINER_RUNTIME |
| 85 | +CRABBOX_LOCAL_CONTAINER_IMAGE |
| 86 | +CRABBOX_LOCAL_CONTAINER_USER |
| 87 | +CRABBOX_LOCAL_CONTAINER_WORK_ROOT |
| 88 | +CRABBOX_LOCAL_CONTAINER_CPUS |
| 89 | +CRABBOX_LOCAL_CONTAINER_MEMORY |
| 90 | +CRABBOX_LOCAL_CONTAINER_NETWORK |
| 91 | +``` |
| 92 | + |
| 93 | +## Behavior |
| 94 | + |
| 95 | +1. `warmup` or a fresh `run` creates a per-lease SSH key. |
| 96 | +2. The provider runs `docker run -d` with Crabbox labels, loopback SSH port |
| 97 | + publishing, and public-key auth environment for the bootstrap script. |
| 98 | +3. The container installs `openssh-server`, `git`, `rsync`, `curl`, and `sudo` |
| 99 | + when the image is Debian/Ubuntu-compatible and missing those tools. |
| 100 | +4. With `--desktop`, the container installs and starts Xvfb, XFCE, x11vnc, |
| 101 | + xdotool, screenshot tools, ffmpeg, noVNC, and websockify without requiring |
| 102 | + systemd. |
| 103 | +5. With `--browser`, the container installs a real package-manager browser |
| 104 | + where the image provides one and writes `/var/lib/crabbox/browser.env`. |
| 105 | +6. Crabbox waits for SSH readiness, syncs tracked and nonignored files into |
| 106 | + `localContainer.workRoot`, and uses the normal SSH executor. |
| 107 | +7. `status`, `list`, and `stop` inspect or remove labeled containers. |
| 108 | + |
| 109 | +## Limits |
| 110 | + |
| 111 | +- Linux target only. |
| 112 | +- No Crabbox coordinator support; lifecycle is local to the machine running the |
| 113 | + CLI. |
| 114 | +- Desktop, browser, VNC, WebVNC, screenshot, video, and desktop input helpers |
| 115 | + are local-only. `webvnc` starts noVNC/websockify on the target and tunnels it |
| 116 | + over SSH; it does not use the authenticated Crabbox portal. |
| 117 | +- No code-server, Tailscale bootstrap, or native checkpoint support yet. |
| 118 | +- `warmup --actions-runner` is not supported; use normal `crabbox run` for |
| 119 | + local container smoke tests or a remote SSH provider for GitHub runner |
| 120 | + registration. |
| 121 | +- The Docker daemon is a powerful local capability. Do not treat this as the |
| 122 | + same host isolation boundary as a remote VM or microVM. |
| 123 | +- The current checkout is synced into the container by default. Crabbox does not |
| 124 | + bind-mount the repo or mount the Docker socket. |
| 125 | +- The default `debian:bookworm` image bootstraps packages on first start. Use a |
| 126 | + prebuilt image with SSH/Git/rsync/desktop/browser packages when startup time |
| 127 | + matters. |
| 128 | + |
| 129 | +## Runtime Notes |
| 130 | + |
| 131 | +The provider expects Docker-compatible behavior for: |
| 132 | + |
| 133 | +- `docker run`; |
| 134 | +- `docker ps`; |
| 135 | +- `docker inspect`; |
| 136 | +- `docker rm`; |
| 137 | +- labels; |
| 138 | +- loopback port publishing. |
| 139 | + |
| 140 | +That keeps the backend portable across Docker Desktop, OrbStack, Colima, and |
| 141 | +other runtimes that expose the standard Docker CLI. Remote Docker contexts are |
| 142 | +not the intended MVP path because Crabbox connects to the published SSH port |
| 143 | +from the local machine. |
| 144 | + |
| 145 | +## Related |
| 146 | + |
| 147 | +- [Provider reference](README.md) |
| 148 | +- [Static SSH](ssh.md) |
| 149 | +- [Sync](../features/sync.md) |
| 150 | +- [Provider backends](../provider-backends.md) |
0 commit comments