Skip to main content
Start with the Runloop Quickstart to use the examples below.

Overview

File Mounts allow you to inject file content directly into your Devbox at creation time. This is ideal for small configuration files, scripts, or any text content that you want to include without uploading to storage first.
For larger files or binary data, consider using Object Mounts instead. For runtime file operations, see Read and Write Files.

Use Cases

File mounts are particularly useful for:
  • Configuration files: Inject JSON, YAML, or TOML configuration
  • Environment files: Add .env files with environment-specific settings
  • Scripts: Include setup scripts or utility scripts
  • SSH keys: Add authorized keys or known hosts
  • Small data files: Include test fixtures or sample data

Creating a File Mount

Use the mounts parameter with type: "file_mount" to inject file content:
devbox = await runloop.devbox.create(
  mounts=[
    {
      "type": "file_mount",
      "target": "/home/user/config.json",
      "content": '{"api_url": "https://api.example.com", "debug": true}'
    }
  ]
)

# Verify the file was created
content = await devbox.file.read("/home/user/config.json")
print(content)  # {"api_url": "https://api.example.com", "debug": true}

File Mount Parameters

ParameterRequiredDescription
typeYesMust be "file_mount"
targetYesAbsolute path where the file should be created
contentYesThe text content of the file

Examples

Mounting a Python Script

script_content = '''#!/usr/bin/env python3

if __name__ == "__main__":
  print("Hello from mounted script!")
'''

devbox = await runloop.devbox.create(
  mounts=[
    {
      "type": "file_mount",
      "target": "/home/user/setup.py",
      "content": script_content
    }
  ]
)

# Run the script
result = await devbox.cmd.exec("python /home/user/setup.py")
print(await result.stdout())  # Hello from mounted script!

Mounting Multiple Configuration Files

devbox = await runloop.devbox.create(
  mounts=[
    {
      "type": "file_mount",
      "target": "/home/user/.env",
      "content": "DATABASE_URL=postgres://localhost:5432/mydb\nAPI_KEY=secret123"
    },
    {
      "type": "file_mount",
      "target": "/home/user/app/config.yaml",
      "content": "server:\n  port: 8080\n  host: 0.0.0.0"
    },
    {
      "type": "file_mount",
      "target": "/home/user/.gitconfig",
      "content": "[user]\n  name = AI Agent\n  email = [email protected]"
    }
  ]
)

Limitations

  • Text content only: File mounts support UTF-8 text content. For binary files, use Object Mounts.
  • Size limits: Individual file mounts have a maximum size limit. For large files, use Object Mounts.
  • Absolute paths: The target path must be an absolute path (e.g., /home/user/file.txt).

Best Practices

  1. Use for small files: File mounts are best for configuration files and small scripts. For larger files, use Object Mounts.
  2. Avoid sensitive data: Don’t include secrets directly in file content. Use Account Secrets instead.
  3. Use absolute paths: Always specify the full path starting with /.
  4. Create parent directories: Parent directories are created automatically if they don’t exist.