agentscope-ai / agentscope-ai/agentscope

[Feature] Add configurable host for accessing sandbox containers when runtime-sandbox-server runs in a Docker container

Đang mở
#1,880 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
stale-issue
Ngôn ngữ chính
Python
Star
31.5k
Fork
3.5k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
95

Mô tả

### Prerequisites

- [x] I have searched the existing [issues](https://github.com/agentscope-ai/agentscope/issues) and [discussions](https://github.com/agentscope-ai/agentscope/discussions), and this is not a duplicate.
- [x] This is a bug, not a usage question. (For questions, please use [Discussions](https://github.com/agentscope-ai/agentscope/discussions/new?category=general) instead.)

### Background / Description

Problem Description
When the sandbox-runtime-server is deployed as a container (e.g., using docker-compose) and manages sandboxes that are also Docker containers, a network connectivity issue arises between the two.

Specifically, the sandbox container created by the sandbox-runtime-server exposes a host port (e.g., 32768). However, the server always attempts to access the sandbox via localhost:{sandbox_port}. If the Runtime server is running inside its own container with network_mode: bridge, localhost refers to the container itself, not the host machine. This causes requests to time out, preventing the server from establishing a connection with the sandbox container.

Proposed Solution
I propose adding a new configuration variable to the runtime-sandbox-server to specify a dedicated access host for sandbox services, rather than automatically defaulting to localhost.

Ideally, if this variable (e.g., SANDBOX_CONTAINER_ACCESS_HOST) is set, the service would use {specified_host}:{exposed_host_port} to access the sandbox. If not set, it would retain the current default behavior of using localhost.

Affected Component(s)
Engine

Sandbox

Common

Tools

Documentation

Other: runtime-sandbox-server

Alternatives Considered
Two alternative solutions have been considered, but each has limitations:

Use Host Network Mode: Setting network_mode: "host" for the runtime-sandbox-server container does resolve the issue but sacrifices network isolation.

Use a Custom Bridge Network: Creating an external bridge network and attaching the sandbox containers to it is possible. However, it remains unclear how the runtime-sandbox-server would be configured to know the access address within that network.

Additional Context
This is a classic Docker-in-Docker (DinD) or Docker-out-of-Docker (DooD) network communication scenario. Implementing this configuration variable would be highly beneficial for production deployments where the Runtime service needs to be containerized while maintaining network isolation from sandbox containers.

Dockerfile (core configuration):

dockerfile
FROM python:3.11-slim-bookworm

ARG AGENTSCOPE_RUNTIME_VERSION=1.1.5

# Only keep environment variables actually read by the Runtime service, some config omitted for brevity
ENV HOST=0.0.0.0
ENV PORT=38000
ENV DEFAULT_SANDBOX_TYPE=filesystem
ENV CONTAINER_DEPLOYMENT=docker
ENV RUNTIME_SANDBOX_TIMEOUT=600

RUN python -m pip install --no-cache-dir "agentscope-runtime==${AGENTSCOPE_RUNTIME_VERSION}"

EXPOSE 38000

CMD ["runtime-sandbox-server", "--log-level", "INFO"]

### Error Messages

```shell
Logs from runtime-manager:

Image

Sandbox info in Redis:

Image
```

### Steps to Reproduce

none

### Environment

- AgentScope Version:1.1.5
- Python Version:3.11-slim-bookworm
- OS: debian12

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.