Docker Sandboxes run each environment in its own microVM, with its own filesystem, network and Docker daemon. The SurrealDB kit, surrealdb/surrealdb-docker-sbx, starts one with SurrealDB already running and the surreal command-line tool on the PATH. Use it for a database you can fill, break and throw away, or hand to a coding agent, without any of that reaching your machine. To run the server from the official image instead, see Docker.
Requirements
The
sbxcommand-line tool. On macOS, install it withbrew trust docker/tap && brew install docker/tap/sbx.A Docker login, created with
sbx login.
Start the sandbox
sbx run git+https://github.com/surrealdb/surrealdb-docker-sbx.gitThe first start installs SurrealDB inside the sandbox. Every start then launches the server in the background and waits until it accepts connections, so your shell opens only when the database is ready. The server listens on port 8000 inside the sandbox, and by default it keeps its data in memory.
To work on the kit itself, or to run it from disk, clone the repository and pass the folder to sbx run. A project directory placed after it is mounted into the sandbox:
git clone https://github.com/surrealdb/surrealdb-docker-sbx
sbx run ./surrealdb-docker-sbx ~/my-projectUse the database
The sandbox sets SURREAL_USER, SURREAL_PASS and SURREAL_ENDPOINT, which the surreal tool reads, so its commands need no credential or endpoint flags. Inside the sandbox shell:
surreal sql --ns demo --db demoThe repository includes examples/seed.surql, a small schema of people, projects and works_on graph edges. Mount a clone of the repository into the sandbox, then import it from there:
surreal import --ns demo --db demo examples/seed.surqlTo reach the database from the host, for example from your own application or from Studio, publish the port when you start the sandbox. sbx ports lists the ports that are currently published.
sbx run git+https://github.com/surrealdb/surrealdb-docker-sbx.git -p 8000:8000 The kit starts SurrealDB with the user root and the password root, reachable only from inside the microVM and from 127.0.0.1 on the host. It is a development environment, so do not put production or sensitive data in it.
Configuration
Set each option as an environment variable with sbx run -e KEY=VALUE.
| Variable | Default | Purpose |
|---|---|---|
SURREAL_STORAGE | memory | The storage engine, memory or rocksdb. |
SURREAL_DATA_DIR | ~/.surrealdb/data | The folder the rocksdb option writes to. |
SURREAL_PATH | unset | Any storage path the CLI accepts, such as surrealkv:/path. It overrides SURREAL_STORAGE. |
SURREAL_BIND | 0.0.0.0:8000 | The address the server listens on inside the sandbox. |
SURREAL_USER, SURREAL_PASS | root, root | The root user, created at the first start. |
SURREAL_ENDPOINT | http://127.0.0.1:8000 | The address the readiness check and your own scripts use. |
Keep data between restarts
In-memory data disappears when the sandbox stops. To keep it across restarts of the same sandbox, choose an on-disk engine:
sbx run git+https://github.com/surrealdb/surrealdb-docker-sbx.git -e SURREAL_STORAGE=rocksdbThe data goes to ~/.surrealdb/data on a 5 GB volume that the kit declares. The volume survives a restart but not sbx rm. In SurrealDB 4.0 the rocksdb option opens the files with SurrealKV and logs a deprecation warning. To select SurrealKV directly, set SURREAL_PATH to a surrealkv: path under ~/.surrealdb.
Network access
A sandbox denies outbound network access by default. The kit opens two domains and nothing else: install.surrealdb.com for the install script, and download.surrealdb.com for the binaries the script fetches.
Next steps
Docker - run the official image directly
Installation - install SurrealDB on your own machine
surreal db start- every storage engine and server option