> For the complete documentation index, see [llms.txt](https://metalbear.com/mirrord/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://metalbear.com/mirrord/docs/using-mirrord/file-operations.md).

# File Operations

By default, mirrord redirects most file access from your local process to the remote pod. When your code opens `/etc/config/app.yaml`, it reads the remote pod's copy. This means your local process sees the same configuration files, certificates, and data that the deployed application does.

Some paths, like language runtimes, package managers, and temp files, are always read locally. See the [full default list](https://github.com/metalbear-co/mirrord/blob/main/mirrord/layer-lib/src/file/unix/read_local_by_default.rs) for details.

### Choosing a mode

mirrord supports three file system modes:

| Mode                 | Behavior                                        | Use when                                                              |
| -------------------- | ----------------------------------------------- | --------------------------------------------------------------------- |
| `read` (default)     | Reads from remote, writes locally               | You want remote config but don't want to risk writing to remote files |
| `local`              | All file access stays local                     | You don't need any remote files                                       |
| `localwithoverrides` | All file access local, except paths you specify | You need just a few specific remote files                             |

```json
{
  "feature": {
    "fs": {
      "mode": "read"
    }
  }
}
```

### Reading specific files remotely

Use `localwithoverrides` when you only need a handful of remote files, for example a config file or TLS certificate:

```json
{
  "feature": {
    "fs": {
      "mode": "localwithoverrides",
      "read_only": ["/etc/config/.*", "/var/secrets/.*"]
    }
  }
}
```

Paths support regex patterns.

### Writing files remotely

If your application writes to files that need to land on the remote filesystem (e.g. uploading to a shared volume), use `read_write`:

```json
{
  "feature": {
    "fs": {
      "read_write": ["/mnt/shared/uploads/.*"]
    }
  }
}
```

Be careful with remote writes. They modify the actual remote pod's filesystem.

### Keeping specific files local

If the default `read` mode pulls in remote files that conflict with your local setup (e.g. `/tmp` files, lock files), you can force them to stay local:

```json
{
  "feature": {
    "fs": {
      "local": ["/tmp/.*", ".*\\.lock"]
    }
  }
}
```

### Common scenarios

**"My app reads config from a mounted ConfigMap"** The default `read` mode handles this. Your local process will read the ConfigMap contents from the remote pod.

**"My app writes logs to a file and I don't want them on the remote pod"** Default `read` mode already writes locally. No change needed.

**"I only need one remote config file, everything else should be local"** Use `localwithoverrides` with the specific path.

For the full list of file operation settings, see the [configuration reference](https://metalbear.com/mirrord/docs/config#feature.fs). For a technical explanation of how file operations work under the hood, see the [File Operations reference](/mirrord/docs/reference/fileops.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://metalbear.com/mirrord/docs/using-mirrord/file-operations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
