Class DockerRunner

java.lang.Object
atessera.sensei.util.DockerRunner

public final class DockerRunner extends Object
Runs commands inside resource limited Docker containers.

Supports both asynchronous background container launch via start(String, Path, ResourceQuota, String) returning an AutoCloseable DockerContainer, and synchronous execution via run(String, Path, ResourceQuota, String).

  • Constructor Details

    • DockerRunner

      public DockerRunner(String dockerExecutable)
      Creates a runner.
      Parameters:
      dockerExecutable - name or path of the Docker CLI; must not be null
  • Method Details

    • start

      public DockerContainer start(String image, Path workDir, ResourceQuota quota, String command) throws IOException
      Starts a command inside a background Docker container and returns a handle for monitoring and cleanup.
      Parameters:
      image - Docker image name
      workDir - laboratory directory mounted at /workspace
      quota - resource limits
      command - shell command executed in the container
      Returns:
      an active DockerContainer handle
      Throws:
      IOException - when the Docker process cannot be started or initialization fails
    • run

      public DockerRunResult run(String image, Path workDir, ResourceQuota quota, String command) throws IOException
      Synchronously runs a command in a background container, waits for completion, captures logs, and cleans up.
      Parameters:
      image - Docker image name
      workDir - laboratory directory mounted at /workspace
      quota - resource limits
      command - shell command executed in the container
      Returns:
      captured exit code and output
      Throws:
      IOException - when the Docker process cannot be started