> 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). # Reading and Writing Remote Files Choose which files your local process reads and writes on the remote pod, and which stay local. 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 by asking a question. Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters: ``` GET https://metalbear.com/mirrord/docs/using-mirrord/file-operations.md?ask=&goal= ``` `ask` is the immediate question: it should be specific, self-contained, and written in natural language. `goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case. 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.