Class DockerSandboxState
java.lang.Object
io.agentscope.harness.agent.sandbox.SandboxState
io.agentscope.harness.agent.sandbox.impl.docker.DockerSandboxState
Serializable state for a Docker-backed
Sandbox.
Persisted after each call to enable transparent container resume. If the container
identified by containerId is still alive on resume, the sandbox reconnects. If
it is stopped, it is restarted. If it has been removed, a new container is created and the
workspace is restored from snapshot.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns additional raw arguments appended todocker run.Returns the Docker container ID.Returns the container name.Returns the optional CPU count limit.int[]Returns the exposed port numbers.getImage()Returns the Docker image used for this container.Returns the optional memory limit in bytes.Returns the docker network mode or network name.Returns the workspace root path inside the container.booleanReturns whether the SDK owns the container lifecycle.voidsetAdditionalRunArgs(List<String> additionalRunArgs) Sets additional raw arguments appended todocker run.voidsetContainerId(String containerId) Sets the Docker container ID.voidsetContainerName(String containerName) Sets the container name.voidsetContainerOwned(boolean containerOwned) Sets whether the SDK owns the container lifecycle.voidsetCpuCount(Long cpuCount) Sets the CPU count limit.voidsetExposedPorts(int[] exposedPorts) Sets the exposed port numbers.voidSets the Docker image.voidsetMemorySizeBytes(Long memorySizeBytes) Sets the memory limit in bytes.voidsetNetwork(String network) Sets the docker network mode or network name.voidsetWorkspaceRoot(String workspaceRoot) Sets the workspace root path inside the container.Methods inherited from class io.agentscope.harness.agent.sandbox.SandboxState
getSessionId, getSnapshot, getWorkspaceProjectionHash, getWorkspaceSpec, isWorkspaceRootReady, setSessionId, setSnapshot, setWorkspaceProjectionHash, setWorkspaceRootReady, setWorkspaceSpec
-
Constructor Details
-
DockerSandboxState
public DockerSandboxState()
-
-
Method Details
-
getContainerId
Returns the Docker container ID.- Returns:
- container ID, or
nullif the container has not been created yet
-
setContainerId
Sets the Docker container ID.- Parameters:
containerId- Docker container ID
-
getContainerName
Returns the container name.- Returns:
- container name
-
setContainerName
Sets the container name.- Parameters:
containerName- container name
-
getImage
Returns the Docker image used for this container.- Returns:
- Docker image
-
setImage
Sets the Docker image.- Parameters:
image- Docker image
-
getWorkspaceRoot
Returns the workspace root path inside the container.- Returns:
- workspace root path
-
setWorkspaceRoot
Sets the workspace root path inside the container.- Parameters:
workspaceRoot- absolute path inside the container
-
isContainerOwned
public boolean isContainerOwned()Returns whether the SDK owns the container lifecycle.- Returns:
trueif the SDK manages container creation and removal
-
setContainerOwned
public void setContainerOwned(boolean containerOwned) Sets whether the SDK owns the container lifecycle.- Parameters:
containerOwned-trueif the SDK should stop and remove the container on shutdown
-
getMemorySizeBytes
Returns the optional memory limit in bytes.- Returns:
- memory limit or
null
-
setMemorySizeBytes
Sets the memory limit in bytes.- Parameters:
memorySizeBytes- memory limit
-
getCpuCount
Returns the optional CPU count limit.- Returns:
- CPU count or
null
-
setCpuCount
Sets the CPU count limit.- Parameters:
cpuCount- number of CPUs
-
getExposedPorts
public int[] getExposedPorts()Returns the exposed port numbers.- Returns:
- port numbers array
-
setExposedPorts
public void setExposedPorts(int[] exposedPorts) Sets the exposed port numbers.- Parameters:
exposedPorts- port numbers
-
getNetwork
Returns the docker network mode or network name.- Returns:
- docker network value, or
nullwhen unset
-
setNetwork
Sets the docker network mode or network name.- Parameters:
network- docker network value
-
getAdditionalRunArgs
Returns additional raw arguments appended todocker run.- Returns:
- additional docker run arguments
-
setAdditionalRunArgs
Sets additional raw arguments appended todocker run.- Parameters:
additionalRunArgs- additional docker run arguments
-