Skip to content

Configuration reference

This page gives the configuration of the daemon: the flags of boxfork serve, the data directory and the files of the service. The page is for a person who installs or operates the daemon on a machine.

The daemon has no configuration file of its own. All its settings are flags of boxfork serve. The installer writes the flags into an environment file and a systemd unit.

Source:

boxfork serve [flags]

The command accepts flags only. If the command line has a word that is not a flag, the daemon does not start. Write a duration with a number and a unit, for example 30s, 15m or 2h.

Flag Default Meaning
--listen <host:port> 127.0.0.1:7070 The address on which the daemon serves the API.
--data-dir <dir> See Data directory The directory for the API key and the state file.
--docker-host <address> DOCKER_HOST, then unix:///var/run/docker.sock The address of the engine. See Engine.
--tls-cert <file> none The certificate file, in PEM format with its chain, to serve the API through HTTPS. It needs --tls-key.
--tls-key <file> none The private key file, in PEM format, for --tls-cert.
Flag Default Meaning
--isolation <mode> auto auto, gvisor or container. See Isolation.
--default-image <image> ubuntu:24.04 The image for a sandbox that names none.
--default-timeout <duration> 5m The life of a sandbox that sets none. The value must be more than zero.
--max-timeout <duration> 0 The longest life that a sandbox can ask for. 0 means no limit.
--max-sandboxes <n> 0 The maximum number of sandboxes at one time. 0 means no limit.
--max-snapshots <n> 0 The maximum number of snapshots at one time. 0 means no limit. Temporary snapshots do not count.
--max-volumes <n> 0 The maximum number of volumes at one time. 0 means no limit.
--max-pooled <n> 64 The maximum number of waiting sandboxes in all pools together. 0 means that the daemon keeps none. Waiting sandboxes do not count for --max-sandboxes.
--connection-idle <duration> 1m The time that the daemon keeps the kept connection of a sandbox open after its last command. 0 gives each command its own connection.
--volume name:/path[:ro] none A volume that the daemon mounts in each new sandbox. :ro mounts it read-only. The daemon creates the volume if it does not exist. You can give this flag more than one time.
--dns <ip> The name servers that the engine uses A name server for sandboxes, as an IP address. You can give this flag more than one time.
--block-metadata <mode> auto auto, require or off. See Metadata service of the cloud.
Flag Default Meaning
--gpu-driver <driver> nvidia The method to attach a GPU: nvidia (NVIDIA Container Toolkit) or cdi.
--gpu-busy-mb <n> 512 The GPU allocator does not give a free GPU that has this quantity of used memory, or more, in MiB. 0 stops this check.
--gpu-idle-suspend <duration> 0 Suspend a sandbox with a GPU after this idle time, for example 15m. 0 means never. A value other than 0 must be 10s or more. A sandbox can set its own time.
--gpu-check <mode> auto The check of a new sandbox with a GPU: auto, require or off. See GPUs.
  • --tls-cert and --tls-key go together. Give the two flags, or none of them.
  • If --max-timeout is set, the daemon refuses a sandbox without a timeout.
  • If --default-timeout is larger than --max-timeout, the daemon uses the --max-timeout value as the default.
  • A negative --max-timeout is an error.
  • A --dns address must not be a loopback address or an unspecified address such as 0.0.0.0.
  • A value of --max-pooled or --connection-idle below zero has the same effect as 0.
  • A wrong flag or a wrong value stops the daemon before it starts a sandbox. The exit status is 1.

These values are in the code. No flag changes them.

Value Quantity
Default CPU cores of a sandbox 2
Default memory of a sandbox 1024 MiB, or 8192 MiB for a sandbox with a GPU
Shared memory (/dev/shm) of a sandbox Half of its memory
Maximum number of processes in a sandbox 4096
Output of a command without a stream 4 MiB each for stdout and stderr
File upload 4 GiB
JSON request body 8 MiB
Forks in one call 64
Volumes in one sandbox 16
Minimum idle time before a suspension 10 seconds

The daemon controls the engine through the Docker Engine API. Docker gives this API, and Podman also gives it.

The daemon finds the address of the engine in this sequence:

  1. The --docker-host flag.
  2. The DOCKER_HOST environment variable.
  3. The default, unix:///var/run/docker.sock.

An address has one of two forms: unix:///path/to/socket or tcp://host:port. A different form is an error. If the engine does not answer at start, the daemon stops with an error.

The daemon makes these objects in the engine:

Object Name in the engine
The container of a sandbox boxfork- and the sandbox identifier
The image of a snapshot boxfork-snapshot: and the snapshot identifier without snap_
A volume boxfork-vol- and the name of the volume
The network of the sandboxes boxfork

The daemon puts the label boxfork.managed=true on each container and each volume that it makes.

Caution: Use one daemon for one engine. At start, a daemon removes each sandbox container that is not in its state file. A second daemon on the same engine removes the sandboxes of the first one.

--isolation selects the mechanism between a sandbox and the kernel of the host.

Mode What the daemon does
auto Use gVisor if it works. If not, use plain containers and write a warning to the log.
gvisor Use gVisor. If gVisor does not work, the daemon does not start.
container Use plain containers. Sandboxes share the kernel of the host. Run only code that you trust.

For auto and gvisor, the daemon does a test at start:

  1. The daemon asks the engine if it has a runtime with the name runsc.
  2. The daemon starts one test container from the default image with that runtime.
  3. The daemon makes sure that the container runs and that the engine used runsc for it.
  4. The daemon removes the test container.

The test can pull the default image. GET /v1/info and each sandbox object report the result as gvisor or container. When the daemon uses gVisor, it also makes sure for each new sandbox that the engine used runsc.

The data directory holds the API key and the state file. The default is the first of these that applies:

  1. The BOXFORK_DATA_DIR environment variable.
  2. /var/lib/boxfork, if the daemon runs as the root user.
  3. .boxfork in the home directory of the user.

The daemon creates the directory with mode 0700 if it does not exist.

File Contents
api-key The API key, on one line. Mode 0600.
state.json The state file: the records of the sandboxes, the snapshots and the pools.
.state-* A temporary file. The daemon writes the new state here and then renames it to state.json.

The data directory has no other files. The engine keeps the containers, the images of the snapshots and the volumes.

At the first start, the daemon makes a random API key and writes it to api-key. The key is abx_ and 48 hexadecimal characters.

  • If the standard error output is a terminal, the daemon prints the new key one time.
  • If not, the daemon writes only the path of the file to the log.
  • At each subsequent start, the daemon reads the key from the file.
  • If other users can read the file, the daemon does not start. Do chmod 600 on the file.
  • If the key in the file is shorter than 16 characters, the daemon does not start.

To make a new key, do these steps:

  1. Stop the daemon.
  2. Delete the file api-key.
  3. Start the daemon. The daemon makes a new key.
  4. Give the new key to each client.

The clients on the same machine read this file. See cli.md.

state.json is a JSON file. The daemon writes it again after each change to a record.

Field Contents
version The format number. It is 1.
sandboxes One record for each sandbox. This includes the waiting sandboxes of the pools.
snapshots One record for each snapshot. Absent when empty.
pools One record for each pool. Absent when empty.
discarded The identifiers of failed snapshots, with a time. The daemon deletes their files from the engine. Absent when empty.

A sandbox record has the fields of the sandbox object of the HTTP API and these fields:

Field Contents
container_id The identifier of the container in the engine. Empty for a suspended sandbox.
fork The temporary snapshot of a fork that is not complete.
pool The pool in which the sandbox waits.
setup A mark of the daemon configuration at the start of a waiting sandbox.
remaining_ns For a paused sandbox, the time that was left, in nanoseconds.
disk The temporary snapshot that holds the files of a suspended sandbox.
gpu_request The GPUs that the client asked for. The daemon uses it when the sandbox wakes.
layers The number of image layers below the container.

The state file does not contain the environment variables of a sandbox, because they can be secrets.

{
"version": 1,
"sandboxes": [
{
"id": "sbx_k3v7q2mzj5xw4n6a",
"image": "python:3.12",
"state": "running",
"isolation": "gvisor",
"cpus": 2,
"memory_mb": 1024,
"network": true,
"created_at": "2026-12-05T10:15:30.412683Z",
"expires_at": "2026-12-05T10:25:30.412683Z",
"container_id": "9c1f4b7d2a6e8035c4d1e7f9a2b6c8d0e3f5a7b9c1d3e5f7a9b1c3d5e7f9a1b3",
"layers": 7
}
],
"snapshots": [
{
"id": "snap_p4c6w2yzr7mq3b5d",
"sandbox_id": "sbx_k3v7q2mzj5xw4n6a",
"image": "python:3.12",
"created_at": "2026-12-05T10:18:44.907115Z"
}
]
}

The daemon writes the state to a temporary file, flushes it to the disk and then renames it. Thus a crash leaves the full old state or the full new state.

Caution: Do not delete or edit the state file. Without its records, the daemon removes all sandbox containers at the next start. The images of the snapshots stay in the engine, but the daemon does not know them.

If the state file is not valid JSON, the daemon does not start.

Without --tls-cert and --tls-key, the daemon serves plain HTTP. With the two flags, the daemon serves HTTPS on the same --listen address. The minimum version is TLS 1.2.

  • The daemon reads the two files one time, before it starts a sandbox. A wrong path stops the daemon.
  • To use a new certificate, restart the daemon.
  • A client then uses an address that starts with https://.
  • If the daemon serves plain HTTP on an address that is not a loopback address, it writes a warning to the log.
Terminal window
boxfork serve --listen 0.0.0.0:7070 \
--tls-cert /etc/boxfork/tls/fullchain.pem --tls-key /etc/boxfork/tls/privkey.pem

The client can use the BOXFORK_PIN_CERT variable to trust one certificate file. See cli.md.

A sandbox with networking is on the engine network boxfork. A sandbox without networking has no network.

At start, the daemon asks the engine if it blocks traffic between sandboxes on that network. GET /v1/info reports the answer as network_isolated. If the answer is no, the daemon writes a warning to the log.

--dns gives the name servers of each sandbox with networking. Without --dns, a sandbox keeps the name servers that the engine gave it. With gVisor, a sandbox cannot connect to the resolver of the engine. The daemon then gives the sandbox the name servers to which the engine sends its requests.

On a cloud machine, the metadata service at 169.254.169.254 can give the credentials of the machine. --block-metadata controls firewall rules that keep sandboxes from this service.

Mode What the daemon does
auto Set the rules if it can. If it cannot, write a message to the log and continue.
require Set the rules. If it cannot, the daemon does not start. It also sets the rules again before each sandbox with networking, and refuses the sandbox if it cannot.
off Set no rules. On a Linux machine with a local engine, remove the rules of an earlier run.
  • The daemon can set the rules only on a Linux machine on which the engine runs. An engine at a tcp:// address of a different machine is out of its control.
  • The daemon sets the rules again each 30 seconds, because a different program can clear them.
  • GET /v1/info reports the result as metadata_blocked.

install.md tells you what to do when the daemon cannot set the rules.

At start, the daemon reads the GPUs of the host with the nvidia-smi program. If the host does not have nvidia-smi, the daemon has no GPUs and continues. The daemon reads the list of devices one time. A restart is necessary after a change of the hardware.

--gpu-driver selects how the daemon asks the engine for a device:

Driver Device names that the daemon gives the engine
nvidia The UUID of each device. The daemon also sets NVIDIA_VISIBLE_DEVICES in the sandbox to these UUIDs.
cdi nvidia.com/gpu= and the index of each device.

--gpu-check selects the check of a new sandbox with a GPU. The daemon asks the sandbox which GPUs it sees.

Mode What the daemon does
auto Remove a sandbox that gives a wrong answer. Accept a sandbox that cannot look, without gpu_verified.
require Remove a sandbox that gives a wrong answer and a sandbox that cannot look.
off Ask nothing.

A sandbox without a GPU gets the value void in NVIDIA_VISIBLE_DEVICES. A client cannot set this variable.

Nobody did a test of the GPU functions on a machine with a real GPU.

The daemon does this work while it runs. The intervals are in the code.

Interval Work
1 second The sweep: kill each sandbox whose timeout ended, close idle kept connections, remove forks that are not complete.
2 seconds Suspend each sandbox that was idle for its suspend_after_seconds.
10 seconds Fill the pools. The daemon also does this immediately after a change to a pool.
20 seconds Compare the records with the engine. Remove the record of a sandbox whose container stopped. Delete temporary snapshots without a sandbox.
30 seconds Set the firewall rules for the metadata service again.

scripts/install.sh installs the daemon as a systemd service on a Linux machine. install.md gives the procedure. This section describes the files that the installer writes.

Path Contents
/usr/local/bin/boxfork The program.
/etc/boxfork/boxfork.env The environment file: the settings of the service. Mode 644.
/etc/systemd/system/boxfork.service The systemd unit. Mode 644.
/var/lib/boxfork The data directory. The daemon creates it at its first start.

The installer writes five settings to /etc/boxfork/boxfork.env:

Setting Installer option Default Meaning
BOXFORK_LISTEN --listen 127.0.0.1:7070 The value of boxfork serve --listen.
BOXFORK_ISOLATION --isolation auto The value of boxfork serve --isolation.
BOXFORK_TLS_CERT --tls-cert empty The certificate file. Empty means plain HTTP.
BOXFORK_TLS_KEY --tls-key empty The private key file. Empty means plain HTTP.
BOXFORK_EXTRA_ARGS --extra-args empty More flags for boxfork serve, written as on a command line.

The file that a first installation writes:

Terminal window
#boxfork# Settings for the boxfork service. After a change: systemctl restart boxfork
#boxfork# Sandboxes keep running across a restart. The installer rewrites the lines
#boxfork# below when it is given new values, and keeps any other line in this file.
#boxfork# A line further down that sets one of these five again is taken as the
#boxfork# value in force and folded into its line here at the next install.
BOXFORK_LISTEN=127.0.0.1:7070
BOXFORK_ISOLATION=auto
#boxfork# The certificate and key the API is served with over HTTPS; empty for plain HTTP.
BOXFORK_TLS_CERT=
BOXFORK_TLS_KEY=
#boxfork# More flags for "boxfork serve", as on a command line. See: boxfork serve --help
BOXFORK_EXTRA_ARGS=

Rules for the file:

  • Put all other flags of boxfork serve in BOXFORK_EXTRA_ARGS, for example --max-sandboxes 50 --default-timeout 15m.
  • Do not put --tls-cert or --tls-key in BOXFORK_EXTRA_ARGS. The installer refuses that.
  • Give the certificate file and the key file as full paths.
  • A value cannot contain a backslash or a line break.
  • When you run the installer again, it keeps each setting for which you give no new value.
  • The installer option --no-tls clears the two certificate settings.
  • The installer keeps the lines that you add to the file.

To change a setting by hand, do these steps:

  1. Edit /etc/boxfork/boxfork.env.
  2. Do the command sudo systemctl restart boxfork.

The sandboxes continue to run while the service restarts.

The installer writes this unit to /etc/systemd/system/boxfork.service:

[Unit]
Description=boxfork: isolated CPU and GPU sandboxes for AI agents
After=docker.service network-online.target
Wants=docker.service network-online.target
[Service]
EnvironmentFile=/etc/boxfork/boxfork.env
# The two certificate flags are always passed; empty values mean plain HTTP.
ExecStart=/usr/local/bin/boxfork serve --listen ${BOXFORK_LISTEN} --isolation ${BOXFORK_ISOLATION} --data-dir /var/lib/boxfork --tls-cert ${BOXFORK_TLS_CERT} --tls-key ${BOXFORK_TLS_KEY} $BOXFORK_EXTRA_ARGS
# Docker being stopped does not stop this service: it carries on and finds
# Docker again when Docker is back. Where Docker is not up yet, it leaves
# and is started again until Docker is.
Restart=on-failure
RestartSec=2
# Sandboxes are containers that Docker runs, not children of this service:
# stopping or restarting it leaves them running, and the daemon picks them
# up again when it starts.
[Install]
WantedBy=multi-user.target
  • The unit has no User line. Thus the daemon runs as the root user.
  • The data directory is always /var/lib/boxfork.
  • systemd starts the service after Docker and after the network.
  • If the daemon stops with an error, systemd starts it again after 2 seconds.
  • The installer enables the service and restarts it. If systemd does not run on the machine, the installer writes the files and prints the command to start the daemon.

The installer option --uninstall removes the unit and the program. It keeps the data directory and /etc/boxfork. It also writes the file /etc/boxfork/installed-by-startup, which stops a first-boot script from a new installation.

When the daemon gets the SIGINT signal or the SIGTERM signal, it stops the API and exits. It gives open requests a maximum of 5 seconds. It does not stop the sandboxes: their containers continue to run in the engine.

At the next start, the daemon reads the state file and compares it with the engine.

The daemon keeps these things:

Thing Condition
A sandbox, with its identifier, files and processes Its container runs.
The paused state of a sandbox The engine tells the daemon if the container is paused. The record follows the engine.
A suspended sandbox The temporary snapshot with its files is in the engine.
The GPUs of a sandbox The host has GPUs. The daemon gives the same devices to the same sandbox again.
The timeout of a sandbox The record has the time of the end. If that time is in the past, the first sweep kills the sandbox.
A snapshot Its image is in the engine.
A pool Its snapshot, if it has one, exists.
A waiting sandbox of a pool The daemon has the same build, isolation, --dns values and default volumes as before. If not, the daemon replaces the waiting sandbox.
A volume Always. The engine keeps the volumes.
The API key The file api-key is in the data directory.

The daemon does not keep these things:

Thing What the daemon does
A sandbox whose container is gone or stopped It drops the record, removes a stopped container and writes a warning to the log.
A sandbox with a GPU on a host that now has no GPU It drops the record and removes the container.
A sandbox container that is not in the state file It removes the container.
A fork that was not complete The first sweep removes it.
The kept connection of each sandbox The first command after the restart opens a new one.
The idle time of each sandbox The idle time starts again at the start of the daemon.
A command that a client ran through the API at the time of the stop The connection ends, and the helper kills the command.
  • One daemon controls one engine on one machine.
  • The daemon has one API key. It has no users and no permissions for each client.
  • The daemon reads its flags only at start. Each change needs a restart.
  • The daemon has no flag for the log format. It writes text lines on the standard error output.
  • The GPU flags (--gpu-driver, --gpu-busy-mb, --gpu-idle-suspend, --gpu-check) ran only against stand-ins, not against a real GPU.
  • ROADMAP.md lists the other things that are not proven, for example the metadata block with nftables.