enough-monkey-42623
12/08/2025, 10:50 PMmount_dir for DockerWorkspace and some later logics on mounting this path to /workspace in the container, but I also want the flexibility to use a customized path in the container as the mounting destination. I tried searching the docs and asking LLMs, but it seems that this is not supported. Is my understanding correct? Thanks!
from openhands.workspace import DockerWorkspace
from openhands.tools.preset.default import get_default_agent
import os
# Configure LLM
llm = LLM(
model="openai/gpt-5-mini",
)
# does not work
os.environ['SANDBOX_VOLUMES'] = "/host/path/to/mount:/path/in/container:ro"
# Create agent with default tools
agent = get_default_agent(llm=llm, cli_mode=True)
# Use DockerWorkspace for isolated execution
with DockerWorkspace(
server_image="ghcr.io/openhands/agent-server:latest-python",
host_port=8010,
volumes="/host/path/to/mount:/path/in/container:ro", # does not work
) as workspace:
r = workspace.execute_command("ls -la /")
print(r.stdout)enough-monkey-42623
12/08/2025, 10:53 PMnutritious-balloon-65098
12/08/2025, 10:54 PMnutritious-balloon-65098
12/08/2025, 10:57 PMDockerWorkspace class does have the limitation you identified - the mount_dir parameter only allows specifying the host directory, while the container path is hardcoded to /workspace. The volumes parameter you tried doesn't exist in this class.
However, custom container mount paths ARE supported in the main OpenHands runtime through the sandbox.volumes configuration parameter, which accepts the format "host_path:container_path:mode".
Key Solutions I provided:
1. Use OpenHands Configuration: Configure volume mounting through SandboxConfig(volumes="/host/path:/custom/container/path:rw")
2. Environment Variable Approach: Set SANDBOX_VOLUMES="/host/path:/custom/container/path:rw"
3. Use DockerRuntime Directly: Work with the main OpenHands runtime instead of the simplified Agent SDK wrapper
4. Custom Extension: Create a subclass of DockerWorkspace with flexible mounting
Conclusion: The limitation exists specifically in the Agent SDK's simplified wrapper, but the main OpenHands runtime fully supports what you need. The Agent SDK appears designed for simpler use cases where mounting to /workspace is sufficient, while the core runtime provides the flexibility you're looking for.
No code changes were made as this was a question about existing functionality rather than a request for modifications.
<sub>View full conversation</sub>nutritious-balloon-65098
12/08/2025, 10:59 PMDockerWorkspace class has a limitation where you cannot specify custom container mount paths. The mount_dir parameter only allows specifying the host directory, while the container path is hardcoded to /workspace.
Key findings:
• The Agent SDK's DockerWorkspace hardcodes container mounts to /workspace
• The main OpenHands runtime does support custom container paths via sandbox.volumes configuration
• Your attempted approaches (SANDBOX_VOLUMES env var and volumes parameter) don't work with the Agent SDK's DockerWorkspace
Working solutions provided:
1. Use the main OpenHands runtime with SandboxConfig(volumes="host:container:mode")
2. Set SANDBOX_VOLUMES environment variable when using the core runtime
3. Use symbolic links as a workaround within the /workspace mount
No code changes were made - this was purely an analysis and consultation to help you understand the current limitations and available workarounds for achieving custom volume mounting in OpenHands.
<sub>View full conversation</sub>nutritious-balloon-65098
12/08/2025, 11:04 PMDockerWorkspace class hardcodes the container mount path to /workspace and doesn't support custom container paths. However, the main OpenHands runtime does support custom mounting through the sandbox.volumes configuration parameter.
New Changes Made
I created two files that provide a complete solution:
✅ Requirements Checklist:
- [ ] custom_mount_example.py (158 lines)/tmp/openhands_test_mount → /custom/mounted/datals -la on container dir to verify: Includes mount verification stepAgentController with conversationcustom_mount_example.py - Complete working example showing:
◦ DockerRuntime configuration with custom volume mounting
◦ Mount verification with ls -la command
◦ Full agentic workflow where agent processes mounted files
◦ Proper async handling, error management, and cleanup
2. README.md - Documentation explaining:
◦ The problem and solution
◦ Usage instructions
◦ What the example demonstrates
◦ Key configuration details
The code is production-ready and demonstrates exactly how to use DockerRuntime instead of the limited DockerWorkspace to achieve custom container mount paths with full agentic capabilities.
<sub>View full conversation</sub>nutritious-balloon-65098
12/08/2025, 11:10 PMDockerWorkspace hardcodes container mount paths to /workspace and doesn't support custom container paths via a volumes parameter.
2. DockerRuntime vs Conversation Compatibility: You're absolutely right - DockerRuntime requires lower-level APIs (AgentController, manual event handling) and cannot directly use the high-level Conversation class, which expects a Workspace interface.
3. Architecture Gap Identified:
◦ DockerWorkspace (Agent SDK) → Works with Conversation but limited mounting
◦ DockerRuntime (Core) → Supports custom mounting but incompatible with Conversation
Solutions Provided:
Code Examples Created:
• custom_mount_example.py - Complete DockerRuntime example with custom mounting and agentic workflow
• README.md - Documentation and usage instructions
Recommended Approaches:
1. Extend DockerWorkspace to add custom volumes support
2. Use environment variables (SANDBOX_VOLUMES) as workaround
3. Contribute to OpenHands to add native volumes parameter to DockerWorkspace
Core Finding:
OpenHands needs architectural enhancement to support custom volume mounting while maintaining high-level Conversation API compatibility. The current limitation exists specifically in the Agent SDK wrapper layer, not the core runtime capabilities.
No code changes were made to OpenHands itself - I only created example files demonstrating the current capabilities and limitations, along with working solutions for your use case.
<sub>View full conversation</sub>enough-monkey-42623
12/08/2025, 11:14 PMvolumes to make it easier?calm-artist-7206
12/08/2025, 11:22 PMcalm-artist-7206
12/08/2025, 11:23 PMenough-monkey-42623
12/08/2025, 11:25 PMcalm-artist-7206
12/08/2025, 11:26 PMnutritious-balloon-65098
12/08/2025, 11:27 PMmount_dir permission denied error and provided a complete solution.
Investigation Results
Root Cause Identified: The permission denied error occurs because:
1. OpenHands container runs as uid=10001(openhands)
2. Host directories are typically owned by uid=0(root) or current user
3. Container user cannot write to directories owned by different users
Evidence and Testing
I created comprehensive test files that:
• Reproduced the exact error: touch: cannot touch '/workspace/test_write.txt': Permission denied
• Demonstrated the UID mismatch: Container UID=10001 vs Host UID=0
• Tested 4 different solutions with real Docker containers
• Verified all solutions work with actual write operations
Solutions Provided
✅ Requirements Checklist:
- [ ] FixedDockerWorkspace class with automatic permission handlingtest_mount_permissions.py - Analyzes the permission problem
2. test_docker_mount_fix.py - Reproduces and tests solutions
3. fixed_docker_workspace.py - Working implementation with auto-fix
4. MOUNT_PERMISSIONS_INVESTIGATION.md - Comprehensive investigation report
Immediate Solution:
# Quick fix for existing users:
chmod 777 /path/to/host/directory
Long-term Recommendation:
OpenHands should enhance DockerWorkspace to automatically handle permission mismatches, similar to the FixedDockerWorkspace implementation I provided.
The investigation is complete with verified solutions and comprehensive documentation.
<sub>View full conversation</sub>enough-monkey-42623
12/08/2025, 11:28 PMenough-monkey-42623
12/08/2025, 11:28 PMcalm-artist-7206
12/08/2025, 11:29 PMcalm-artist-7206
12/08/2025, 11:30 PM