Skip to content

Add support for custom volume mounts in DockerRuntime #8239

@Shimada666

Description

@Shimada666

What problem or use case are you trying to solve?
Currently, the DockerRuntime only supports mounting the workspace directory into the container. However, there are use cases where users need to mount additional directories from the host machine into the container, such as:

  • Mounting read-only model directories (like pre-trained ML models)
  • Accessing shared data directories
  • Mounting temporary storage for downloads or generated content
  • Using host machine's cached dependencies to improve performance

This is particularly useful when working with large datasets or models that already exist on the host machine and should be accessible from within the runtime environment.

Describe the UX or technical implementation you have in mind
I suggest implementing a new environment variable CUSTOM_VOLUMES that allows users to specify additional volume mounts in the following format:

CUSTOM_VOLUMES=/host/path1:/container/path1:rw,/host/path2:/container/path2:ro

Each mount specification consists of three parts:

  • Host path: The path on the host machine
  • Container path: Where to mount it inside the container
  • Access mode: rw for read-write or ro for read-only

Multiple mounts would be separated by commas. The DockerRuntime would parse this environment variable and add these additional mounts when creating the container.

For example, users could run:

docker run -it -d \
    -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.36-nikolaik \
    -e LOG_ALL_EVENTS=true \
    -e CUSTOM_VOLUMES="/opt/openhands/workspace:/workspace:rw,/mnt/data1:/data1:ro" \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v ~/.openhands-state:/.openhands-state \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    --name openhands-app \
    docker.all-hands.dev/all-hands-ai/openhands:0.36

Additional context

If you find this feature request or enhancement useful, make sure to add a 👍 to the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions