Skip to content

Running

Docker Sandboxes kit

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.

  • The sbx command-line tool. On macOS, install it with brew trust docker/tap && brew install docker/tap/sbx.

  • A Docker login, created with sbx login.

sbx run git+https://github.com/surrealdb/surrealdb-docker-sbx.git

The 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-project

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 demo

The 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.surql

To 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
Warning

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.

Set each option as an environment variable with sbx run -e KEY=VALUE.

VariableDefaultPurpose
SURREAL_STORAGEmemoryThe storage engine, memory or rocksdb.
SURREAL_DATA_DIR~/.surrealdb/dataThe folder the rocksdb option writes to.
SURREAL_PATHunsetAny storage path the CLI accepts, such as surrealkv:/path. It overrides SURREAL_STORAGE.
SURREAL_BIND0.0.0.0:8000The address the server listens on inside the sandbox.
SURREAL_USER, SURREAL_PASSroot, rootThe root user, created at the first start.
SURREAL_ENDPOINThttp://127.0.0.1:8000The address the readiness check and your own scripts use.

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=rocksdb

The 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.

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.

Was this page helpful?

Last updated