Class DockerSandboxState

java.lang.Object
io.agentscope.harness.agent.sandbox.SandboxState
io.agentscope.harness.agent.sandbox.impl.docker.DockerSandboxState

public class DockerSandboxState extends SandboxState
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 Details

    • DockerSandboxState

      public DockerSandboxState()
  • Method Details

    • getContainerId

      public String getContainerId()
      Returns the Docker container ID.
      Returns:
      container ID, or null if the container has not been created yet
    • setContainerId

      public void setContainerId(String containerId)
      Sets the Docker container ID.
      Parameters:
      containerId - Docker container ID
    • getContainerName

      public String getContainerName()
      Returns the container name.
      Returns:
      container name
    • setContainerName

      public void setContainerName(String containerName)
      Sets the container name.
      Parameters:
      containerName - container name
    • getImage

      public String getImage()
      Returns the Docker image used for this container.
      Returns:
      Docker image
    • setImage

      public void setImage(String image)
      Sets the Docker image.
      Parameters:
      image - Docker image
    • getWorkspaceRoot

      public String getWorkspaceRoot()
      Returns the workspace root path inside the container.
      Returns:
      workspace root path
    • setWorkspaceRoot

      public void setWorkspaceRoot(String workspaceRoot)
      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:
      true if the SDK manages container creation and removal
    • setContainerOwned

      public void setContainerOwned(boolean containerOwned)
      Sets whether the SDK owns the container lifecycle.
      Parameters:
      containerOwned - true if the SDK should stop and remove the container on shutdown
    • getMemorySizeBytes

      public Long getMemorySizeBytes()
      Returns the optional memory limit in bytes.
      Returns:
      memory limit or null
    • setMemorySizeBytes

      public void setMemorySizeBytes(Long memorySizeBytes)
      Sets the memory limit in bytes.
      Parameters:
      memorySizeBytes - memory limit
    • getCpuCount

      public Long getCpuCount()
      Returns the optional CPU count limit.
      Returns:
      CPU count or null
    • setCpuCount

      public void setCpuCount(Long cpuCount)
      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

      public String getNetwork()
      Returns the docker network mode or network name.
      Returns:
      docker network value, or null when unset
    • setNetwork

      public void setNetwork(String network)
      Sets the docker network mode or network name.
      Parameters:
      network - docker network value
    • getAdditionalRunArgs

      public List<String> getAdditionalRunArgs()
      Returns additional raw arguments appended to docker run.
      Returns:
      additional docker run arguments
    • setAdditionalRunArgs

      public void setAdditionalRunArgs(List<String> additionalRunArgs)
      Sets additional raw arguments appended to docker run.
      Parameters:
      additionalRunArgs - additional docker run arguments