# Sandboxing & Environments

Shipyard runs agent evaluations inside isolated environments to prevent arbitrary file modifications or commands from affecting the host machine.

---

## Configuration

Set the environment in `eval.toml` under the `[environment]` section:

```toml
[environment]
type = "docker"
dockerfile = "environment/Dockerfile"
workdir = "/workspace"
env_vars = { CGO_ENABLED = "0", GOOS = "linux" }
```

---

## Environment Types

### 1. Docker (`docker`)

Builds or runs containers using the local Docker engine.

```toml
# Build from Dockerfile
[environment]
type = "docker"
dockerfile = "environment/Dockerfile"
workdir = "/app"

# Or use an existing prebuilt image
[environment]
type = "docker"
image = "python:3.11-slim"
workdir = "/app"
```

#### Key Options:
- **`dockerfile`**: Path to the Dockerfile to build.
- **`image`**: Prebuilt Docker image name (if not using `dockerfile`).
- **`workdir`**: Working directory inside the container.
- **`env_vars`**: Key-value dictionary of environment variables passed into the container.
- **`persistent`**: Set `true` to keep the container state between steps.

---

### 2. Local (`local`)

Executes agents directly on the host system without container overhead.

```toml
[environment]
type = "local"
workdir = "."
```

---

## CLI Overrides

Override the configured environment at runtime without modifying `eval.toml`:

```bash
# Force evaluation to run in local process sandbox
shipyard run ./my-eval --env local

# Force evaluation to run in Docker
shipyard run ./my-eval --env docker

# Keep the sandbox running after the evaluation finishes (for inspection and debugging)
shipyard run ./my-eval --keep-env
```
