Package atessera.sensei.util
Class DockerRunner
java.lang.Object
atessera.sensei.util.DockerRunner
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrun(String image, Path workDir, ResourceQuota quota, String command) Synchronously runs a command in a background container, waits for completion, captures logs, and cleans up.start(String image, Path workDir, ResourceQuota quota, String command) Starts a command inside a background Docker container and returns a handle for monitoring and cleanup.
-
Constructor Details
-
DockerRunner
Creates a runner.- Parameters:
dockerExecutable- name or path of the Docker CLI; must not benull
-
-
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 nameworkDir- laboratory directory mounted at/workspacequota- resource limitscommand- shell command executed in the container- Returns:
- an active
DockerContainerhandle - 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 nameworkDir- laboratory directory mounted at/workspacequota- resource limitscommand- shell command executed in the container- Returns:
- captured exit code and output
- Throws:
IOException- when the Docker process cannot be started
-