Add Docker container support for Linux
enhancement
## Problem
The current containerization implementation (Phase 1 & 2) uses macOS-specific `container` CLI tool via `AppleContainerRuntime`. This doesn't work on Linux systems.
## Requirements
- Support Docker containers on Linux
- Provide same functionality as AppleContainerRuntime
- Use existing ContainerRuntime interface for consistency
## Implementation Approach
Create a `DockerContainerRuntime` that:
- Implements the `ContainerRuntime` interface
- Uses Docker CLI or Docker SDK for Node.js
- Provides equivalent isolation and mounting capabilities
- Works with existing `WorkspaceContainerManager`
## Technical Details
The ContainerRuntime interface already exists:
```typescript
interface ContainerRuntime {
create(config: ContainerConfig): string | Promise<string>;
start(containerId: string): Promise<void>;
stop(containerId: string, timeout?: number): Promise<void>;
remove(containerId: string): Promise<void>;
exec(containerId: string, options: ExecOptions): Promise<ExecResult>;
inspect(containerId: string): ContainerInfo | Promise<ContainerInfo>;
list(): ContainerInfo[] | Promise<ContainerInfo[]>;
translateToContainer(hostPath: string, containerId: string): string;
translateToHost(containerPath: string, containerId: string): string;
}
```
## Platform Detection
- Runtime selection should be automatic based on platform
- Could use factory pattern: `ContainerRuntimeFactory.create()`
- macOS → AppleContainerRuntime
- Linux → DockerContainerRuntime
- Windows → Could use WSL2 + Docker
## Dependencies
- Docker daemon must be running
- Consider graceful degradation if Docker not available
- May need `dockerode` npm package or use Docker CLI
## Related
- Phase 1: Container Runtime (currently macOS only)
- Cross-platform support
- Container abstraction layer
## Acceptance Criteria
- [ ] DockerContainerRuntime implements ContainerRuntime interface
- [ ] Works on Linux with Docker installed
- [ ] All existing tests pass with Docker backend
- [ ] Automatic runtime selection based on platform
- [ ] Documentation for Docker setup requirements
- [ ] Tests run on Linux CI
关闭于 2026-05-25 0 条评论