SYSTEM_DOCUMENTATION_V2.0

Ghost Machines

v1.0.0-beta · MIT · ▶ Demo 1.8 min
GITHUB · GHCR
4 ENGINES · 4 GHCR PACKAGES · 7 MCP · 8 SCRIPTS
MODE:

1. Core Concept

Ghost Machines is a hotel for developers.

Each container is a sealed room sharing the building's foundation (host kernel) but with its own walls. You check in, you work, you check out — the building stays pristine.

Check in with make start. Work in mounts/. Check out with clean.sh — nothing leaks to your host.

This is not a VM — no hypervisor. Boots in 1–2 seconds, idles at ~73 MB.

IaC disposable workstations via docker-compose.yml + entrypoint.sh.

Declarative images + bind-mount state. UID/GID sync cures permission hell. LXCFS makes free/htop report cgroup limits, not host totals.

GHCR multi-arch prebuilts on v* tags — pull, don’t build. Immutable core + mutable state = throw-away without loss.

2. Intended Audience

Use Ghost if you want a clean, repeatable place to code without polluting your laptop.

Use it for teaching or renting dev rooms to others.

Don't use it for Windows apps or to test viruses (use a real VM).

Target: Linux coders, devops engineers, AI-agent integrators, classrooms, VPS resellers.

Not for: kernel/driver work, Windows-only software, malware detonation.

For those, see Ghost vs VM.

3. Engines & GHCR Sizes → dedicated page

Four engines, identical toolchain. Pull one — not four. Published on v* tags via .github/workflows/publish.yml, multi-arch linux/amd64,arm64.

EngineBaseGHCR PackageSize amd64 / arm64Pull
ubuntuubuntu:latestghost-machine-ubuntu:latest1.38 / 1.21 GBdocker pull ghcr.io/1999azzar/ghost-machine-ubuntu:latest
debiandebian:stable-slimghost-machine-debian:latest1.36 / 1.20 GBdocker pull ghcr.io/1999azzar/ghost-machine-debian:latest
alpinealpine:latestghost-machine-alpine:latest1.59 / 1.32 GBdocker pull ghcr.io/1999azzar/ghost-machine-alpine:latest
archarchlinux:latestghost-machine-arch:latest1.63 / 1.63 GBdocker pull ghcr.io/1999azzar/ghost-machine-arch:latest

4. Deployment Modes

ModeContainersCPU / RAM (each)Use
dualghost-machine1, ghost-machine21 core / 8 GBclient-server, multi-node
singleghost-machine-single1 core / 8 GBstandard workspace
powerghost-machine-power2 cores / 16 GBheavy builds
halfghost-machine-half50% host CPUs / 50% host RAMscale to host

Modes select deploy.resources.limits in docker-compose.yml. LXCFS auto-mounts in /proc/cpuinfo,/proc/meminfo,etc for accurate htop/free reporting.

5. Host Prerequisites

Any Linux, macOS, or Windows host with Docker. Linux users get the best experience (LXCFS, host UID sync).

Linux x86_64 / aarch64, macOS 13+ (OrbStack or Docker Desktop), Windows 11 + WSL2.

Docker Engine ≥ 20.10, Compose v2.

make setup-host on Linux installs LXCFS + Docker if missing. macOS/WSL auto-skip LXCFS via start.sh:50.

6. User Management & Authentication

Tenant-based: each host can vend many isolated users. Each tenant is a specimen with its own SSH port, CPU/RAM quotas, and storage mounts/tenants/<id>.

Roles

HOST — Full access. Runs tenant.sh, clean.sh, manages GHCR pulls, edits .env.
TENANT (developer) — SSH on assigned port, sudo with ghost, owns mounts/tenants/<id>. Cannot see other tenants.

Registration Flow

  1. Host: ./tenant.sh add alice --engine debian --port 2225 — auto-creates mount and SSH.
  2. Tenant: ssh -p 2225 developer@localhost — pass ghost or pre-injected ~/.ssh/id_ed25519.pub.
  3. Verify: ./tenant.sh list shows RUNNING + port + size.

7. Multi-Tenant Aggregation Hub → dedicated

One host aggregates multiple engines into a unified ghost_sandbox bridge network.

Each tenant is isolated via non-overlapping mounts and per-tenant cgroup limits — no noisy neighbor. Tenants share the network but not the storage.

Cross-engine logic: one host can run Ubuntu for Rust, Alpine for Go, Debian for Node — all on different ports, sharing host kernel but not files.

8. GHCR Feeds (Prebuilt Integration)

Instead of building locally, pull curated prebuilts from GHCR. Published on v* tags, multi-arch linux/amd64,arm64, scoped per-engine so Packages tab shows 4 distinct packages.

docker pull ghcr.io/1999azzar/ghost-machine-ubuntu:latest
GHOST_IMAGE=ghcr.io/1999azzar/ghost-machine-ubuntu:latest ./start.sh -e ubuntu -m single
ssh -p 2223 developer@localhost # pass ghost

9. Snapshot Retention

snapshot.sh tars mounts/ excluding caches (node_modules/.cache, target/, __pycache__, .pytest_cache, logs).

It writes companion .sha256 + .meta.json (host arch, timestamp, file count, hash).

restore.sh verifies SHA and keeps atomic backup — rolls back on failure.

./snapshot.sh -o backup.tar.gz
./restore.sh backup.tar.gz --force

10. Engine Specimens

UBUNTU (STANDARD)ubuntu:latest · apt-get · PPA — Default for agents, richest toolchain.
DEBIAN (SLIM)debian:stable-slim · apt-get — Stable, smallest apt base.
ALPINE (MUSL)alpine:latest · apk — Ultra-light, musl libc.
ARCH (ROLLING)archlinux:latest · pacman — Latest upstream.

Each ships the same stack:

Go 1.24, Rust rustup minimal, Node 22 + Bun, Python uv/pipx, build-essential/cmake/gdb.

Helix 25.01.1, Micro, Lazygit, Tmux, agy/opencode/kilo + rtk, 7 HeLa MCP servers + Conductor.

11. Layout Customization

Persistent: tenant mounts under mounts/tenants/<id> survive reboots and container recreation.

Layout is host-file, not ephemeral.

Rearranging = re-adding with different --port/--cpu/--mem or moving the folder on host.

12. Auto-Provisioning

Zero-touch provisioning:

./start.sh -e ubuntu -m single auto-builds if no GHCR image is found.

./tenant.sh add alice --engine debian auto-allocates a port from 2225 if omitted.

make setup-host on Linux installs LXCFS + Docker if missing.

./start.sh -e alpine -m power # 2c/16G
./tenant.sh add carol --engine alpine --port 2227 # explicit port
./start.sh --no-lxcfs -t $TUNNEL_TOKEN # Cloudflare remote

13. Logic Matrix

  1. LISTEN & MATCH — Match engine + mode + GHOST_IMAGE to compose profile (dual/single/power/half).
  2. EVALUATE — Resolve UID/GID, LXCFS, SSH key, tunnel token, host AGY binary.
  3. IF/ELSE IF — If GHCR image exists → reuse (GHOST_IMAGE honored); else → build via Buildx.
  4. WEBHOOK DISPATCH — Cloudflare Tunnel if TUNNEL_TOKEN set.
  5. INTER-WIRING — Tenant snapshots chain to restore (max depth enforced).
  6. MANUAL OVERRIDE./clean.sh --nuke for full purge test.

14. How-To Guide ▶ watch 1.8 min demo

Demo

Single Workspace (Beginner)

  1. git clone https://github.com/1999AZZAR/ghost-machines.git && cd ghost-machines
  2. make setup-host (once, Linux)
  3. docker pull ghcr.io/1999azzar/ghost-machine-ubuntu:latest
  4. GHOST_IMAGE=ghcr.io/1999azzar/ghost-machine-ubuntu:latest ./start.sh -e ubuntu -m single
  5. ssh -p 2223 developer@localhost — pass ghost

Multi-Tenant (WaaS)

# prebuilt
docker pull ghcr.io/1999azzar/ghost-machine-debian:latest
./tenant.sh add alice --engine debian --port 2225
./tenant.sh add bob --engine ubuntu --cpu 4 --mem 8G

# or build locally
./tenant.sh add alice --engine debian --build

# manage
./tenant.sh list · stats · snapshot alice · delete bob -y

15. Security Protocol

Multi-layered, but container is not a security boundary — for hostile code use a real VM.

LayerWhat
Defaultsdeveloper:ghost / root:ghost — dev-only; rotate to key-only for any real use
SSHKey-only via SSH_PASSWORD_AUTH=false, per-tenant authorized_keys
IdentityUID/GID sync via entrypoint.sh
RemoteCloudflare Tunnel (zero-trust), GHCR via GITHUB_TOKEN

16. Ghost vs VM → dedicated

GhostVM
EngineDocker + composeKVM / QEMU / VirtualBox
Boot1–2s30–120s
Idle RAM~73 MB0.5–2 GB
Kernelshared hostown
Isolationweak (container escape = host)strong (hypervisor boundary)
Usedisposable dev, agents, WaaS, CIWindows, kernel, malware

17. Scripts → dedicated page

Hotel staff — each script is a role.

ScriptRole
start.shFront desk — pick engine/mode, sync UID/GID, wire LXCFS/GHCR
tenant.shManager — vend many isolated rooms (WaaS)
snapshot/restoreBackup + verified undo (SHA, atomic rollback)
clean.shHousekeeping — L1–4, L4 = full GHCR nuke

Full scripts (8 staff) →

18. Cleanup → dedicated

LevelCommandEffect
1./clean.sh -sdown (containers + network)
2./clean.sh -vdown -v (incl. volumes)
3./clean.sh -a -ydown -v --rmi local + rmi *-template:latest
4./clean.sh --nuke -yL3 + rmi ghcr ghost-machine-*:latest + builder prune
4 hard./clean.sh --nuke --hard -yL4 + wipe mounts/ (true 1st-user nuke)

19. Troubleshooting

20. Verified Hosts

Successfully tried on both local workstation and VPS.

LOCAL — lappy
Debian GNU/Linux 13 (trixie) · 7.1.8+deb13-amd64
Intel Core i5-10310U (4C/8T @ 1.70–4.40 GHz) · 31 Gi RAM · 55 Gi Swap
836 GB NVMe (38% used) · Docker 29.7.2 · x86_64
VPS — servy
Ubuntu 24.04.4 LTS (Noble) · 6.17.0-1020-oracle aarch64
ARM Neoverse-N1 (2C) · 11 Gi RAM · 11 Gi Swap
193 GB (51% used) · Docker 29.7.2 · aarch64 (Oracle) · up 10 days

Both pull and run GHCR multi-arch images: ghost-machine-*:latest auto-selects amd64/arm64.

21. Glossary → dedicated page

Every term Ghost uses, defined plainly for beginners.

TermPlain Meaning
ContainerSealed room sharing host kernel — 1–2s boot, not a VM
WaaS / CDEVending many isolated workspaces on one host/cloud
Mountmounts/ — your work that survives deletion
GHCRPrebuilt images on v* tags — pull, don’t build

Full glossary (30 terms) →

22. References

GHOST_MACHINES · ARCHIVE 001 · MIT · github.com/1999AZZAR/ghost-machines