DockerClient
public class DockerClient extends BaseClient
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:36–714Docker 客户端,封装与远端服务的连接和调用。位于 io.agentscope.runtime.sandbox.manager.client 包,继承自 BaseClient。核心成员包括 connectDocker、connect、isConnected、createContainer、startContainer、stopContainer。
A class in io.agentscope.runtime.sandbox.manager.client that deploys, schedules and serves agents. Declared in io.agentscope.runtime.sandbox.manager.client. Extends BaseClient.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public DockerClient() | 初始化 `DockerClient` 实例。 Default constructor without configuration |
public DockerClient(DockerClientConfig config) | 初始化 `DockerClient` 实例。 Constructor with DockerClientConfig |
public DockerClient(DockerClientConfig config, PortManager portManager) | 初始化 `DockerClient` 实例。 Creates a new instance. |
方法摘要Method Summary
构造器详情Constructor Detail
DockerClient
public DockerClient()
初始化 DockerClient 实例。
Default constructor without configuration
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:47–50DockerClient
public DockerClient(DockerClientConfig config)
初始化 DockerClient 实例。
Constructor with DockerClientConfig
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | DockerClientConfig | 配置对象(类型 `DockerClientConfig`)。The config. |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:55–57DockerClient
public DockerClient(DockerClientConfig config, PortManager portManager)
初始化 DockerClient 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | DockerClientConfig | 配置对象(类型 `DockerClientConfig`)。The config. |
portManager | PortManager | port 管理器(类型 `PortManager`)。The port manager. |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:59–62方法详情Method Detail
connectDocker
public void connectDocker()
执行 connectDocker 方法。
Returns the connect docker.
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:64–68connect
public boolean connect()
建立连接并完成初始化。
Returns the connect.
booleanio/agentscope/runtime/sandbox/manager/client/DockerClient.java:70–82isConnected
public boolean isConnected()
判断是否已连接。
Returns whether the connected.
booleanio/agentscope/runtime/sandbox/manager/client/DockerClient.java:84–87createContainer
public ContainerCreateResult createContainer(String containerName, String imageName, List<String> ports, List<VolumeBinding> volumeBindings, Map<String, String> environment, Map<String, Object> runtimeConfig)
创建容器。
Creates the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerName | String | 容器名称(类型 `String`)。The container name. |
imageName | String | 图像名称(类型 `String`)。The image name. |
ports | List<String> | ports(类型 `List`)。The ports. |
volumeBindings | List<VolumeBinding> | volume Bindings(类型 `List`)。The volume bindings. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
runtimeConfig | Map<String, Object> | 运行时配置(类型 `Map`)。The runtime config. |
ContainerCreateResultio/agentscope/runtime/sandbox/manager/client/DockerClient.java:89–131startContainer
public void startContainer(String containerId)
启动容器。
Starts the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:157–163stopContainer
public void stopContainer(String containerId)
停止容器。
Stops the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:165–171removeContainer
public void removeContainer(String containerId)
移除容器。
Removes the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:173–189getContainerStatus
public String getContainerStatus(String containerId)
获取容器状态。
Returns the container status.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerId | String | 容器标识(类型 `String`)。The container id. |
Stringio/agentscope/runtime/sandbox/manager/client/DockerClient.java:191–197connectDocker
public com.github.dockerjava.api.DockerClient connectDocker(String dockerInstance)
设置该参数。
Performs the connect docker operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
dockerInstance | String | Docker 实例(类型 `String`)。The docker instance. |
com.github.dockerjava.api.DockerClientio/agentscope/runtime/sandbox/manager/client/DockerClient.java:243–256createContainers
public CreateContainerResponse createContainers(com.github.dockerjava.api.DockerClient client, String containerName, String imageName)
创建容器(简单版本)。
Create container (simple version)
说明Notes
- 注意:该行为受运行时配置或底层实现影响,建议结合对应源码与版本说明确认。@return:: CreateContainerResponse
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
containerName | String | 容器名称(类型 `String`)。container name |
imageName | String | 图像名称(类型 `String`)。image name |
CreateContainerResponseio/agentscope/runtime/sandbox/manager/client/DockerClient.java:266–270createContainers
public CreateContainerResponse createContainers(com.github.dockerjava.api.DockerClient client, String containerName, String imageName, List<String> ports, Map<String, Integer> portMapping, List<VolumeBinding> volumeBindings, Map<String, String> environment, Map<String, Object> runtimeConfig)
创建 createContainers。
Create container (supports port mapping)
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
containerName | String | 容器名称(类型 `String`)。container name |
imageName | String | 图像名称(类型 `String`)。image name |
ports | List<String> | ports(类型 `List`)。port mapping list, format like ["80/tcp", "443/tcp"] |
portMapping | Map<String, Integer> | port Mapping(类型 `Map`)。port mapping Map, key is container port, value is host port |
volumeBindings | List<VolumeBinding> | volume Bindings(类型 `List`)。volume mount mapping, using VolumeBinding object |
environment | Map<String, String> | 环境(类型 `Map`)。environment variables |
runtimeConfig | Map<String, Object> | 运行时配置(类型 `Map`)。runtime configuration |
CreateContainerResponseio/agentscope/runtime/sandbox/manager/client/DockerClient.java:285–355startContainer
public void startContainer(com.github.dockerjava.api.DockerClient client, String containerId)
启动容器。
Start container
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
containerId | String | 容器标识(类型 `String`)。container ID |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:548–555stopContainer
public void stopContainer(com.github.dockerjava.api.DockerClient client, String containerId)
停止容器。
Stop container
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
containerId | String | 容器标识(类型 `String`)。container ID |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:563–575removeContainer
public void removeContainer(com.github.dockerjava.api.DockerClient client, String containerId)
移除容器。
Delete container
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
containerId | String | 容器标识(类型 `String`)。container ID |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:583–594getContainerStatus
public String getContainerStatus(com.github.dockerjava.api.DockerClient client, String containerId)
获取容器状态。
Get container status
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
containerId | String | 容器标识(类型 `String`)。container ID |
Stringio/agentscope/runtime/sandbox/manager/client/DockerClient.java:603–611stopAndRemoveContainer
public void stopAndRemoveContainer(com.github.dockerjava.api.DockerClient client, String containerId)
停止和移除容器。
Stop and delete container
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
containerId | String | 容器标识(类型 `String`)。container ID |
io/agentscope/runtime/sandbox/manager/client/DockerClient.java:619–622imageExists
public boolean imageExists(String imageName)
设置该参数。
Performs the image exists operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
imageName | String | 图像名称(类型 `String`)。The image name. |
booleanio/agentscope/runtime/sandbox/manager/client/DockerClient.java:624–630pullImage
public boolean pullImage(String imageName)
设置该参数。
Performs the pull image operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
imageName | String | 图像名称(类型 `String`)。The image name. |
booleanio/agentscope/runtime/sandbox/manager/client/DockerClient.java:632–638inspectContainer
public boolean inspectContainer(String containerIdOrName)
设置该参数。
Performs the inspect container operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
containerIdOrName | String | 容器标识或名称(类型 `String`)。The container id or name. |
booleanio/agentscope/runtime/sandbox/manager/client/DockerClient.java:640–651imageExists
public boolean imageExists(com.github.dockerjava.api.DockerClient client, String imageName)
执行 imageExists 方法。
Check if image exists locally
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
imageName | String | 图像名称(类型 `String`)。image name |
booleanio/agentscope/runtime/sandbox/manager/client/DockerClient.java:660–680pullImage
public boolean pullImage(com.github.dockerjava.api.DockerClient client, String imageName)
执行 pullImage 方法。
Pull image from registry
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | com.github.dockerjava.api.DockerClient | 客户端(类型 `com.github.dockerjava.api.DockerClient`)。Docker client |
imageName | String | 图像名称(类型 `String`)。image name |
booleanio/agentscope/runtime/sandbox/manager/client/DockerClient.java:689–713