Compose

class Compose

Discovery, logs and controls for existing Compose containers. No CLI or source files are needed. The caller owns the supplied client; this integration never closes it. HTTP failures return SDK errors; transport/decoding failures and cancellation propagate. Snapshots are not atomic: a container removed between list and inspect can fail discovery.

Constructors

Link copied to clipboard
constructor(client: DockerClient)

Functions

Link copied to clipboard
suspend fun discover(): Result<ComposeDiscovery, ErrorResponse>

Lists all containers, inspects Compose-labeled candidates, and groups them by label values. Includes stopped containers and incomplete labels. Projects without remaining containers (including network/volume-only projects) are not discovered. No label paths are opened.

Link copied to clipboard
suspend fun getProject(name: String): Result<ComposeProject?, ErrorResponse>

Returns the observed project, or successful null if it has no discovered containers.

Link copied to clipboard
suspend fun getService(project: String, service: String): Result<ComposeService?, ErrorResponse>

Returns the observed service, or successful null if no such service was discovered.

Link copied to clipboard
fun logs(project: String, service: String, parameters: ContainerLogsParameters = ContainerLogsParameters(), includeOneOff: Boolean = true, maxStreams: Int = 64): Flow<ComposeLogLine>

Reads all replicas of one service; equivalent to logs(project, setOf(service), ...).

fun logs(project: String, services: Set<String>? = null, parameters: ContainerLogsParameters = ContainerLogsParameters(), includeOneOff: Boolean = true, maxStreams: Int = 64): Flow<ComposeLogLine>

Cold, backpressured flow: discovers once per collection and opens one log stream per selected container. Fails before opening streams if the selection exceeds maxStreams. New replicas require recollection. Missing projects/services produce an empty flow. One-off and unknown one-off containers are included by default; false selects only confirmed regular replicas. services selects exact service names: null includes all containers (even without service labels); an empty set produces an empty flow without Docker requests. Blank names are rejected. The supplied set is copied when this method is called.

Link copied to clipboard
suspend fun restart(project: String, service: String, includeOneOff: Boolean = false, timeoutSeconds: Int? = null): Result<ComposeOperationReport, ErrorResponse>

Restart existing regular replicas of one service. See the service-set overload.

suspend fun restart(project: String, services: Set<String>? = null, includeOneOff: Boolean = false, timeoutSeconds: Int? = null): Result<ComposeOperationReport, ErrorResponse>

Restart existing containers selected by exact project and service labels. Null services selects the whole project; an empty set makes no Docker requests. By default only confirmed regular replicas are included; includeOneOff also includes one-off containers and containers with unknown one-off metadata. Discovery completes before mutations. Requests run sequentially in snapshot order, continuing after HTTP errors and preserving each SDK result in the returned report. Start/stop accept HTTP 304 (already in the requested state) as success. An outer success means the batch completed, not that every container succeeded. Missing projects/services produce an empty report. No resources are created or removed. Transport/decoding failures and cancellation propagate, stopping subsequent requests; already applied changes remain and a failed request may have reached Docker. No dependency ordering, readiness checks, retries or rollback are provided. timeoutSeconds is the per-container stop grace period: null uses Docker defaults, -1 waits indefinitely, 0 kills immediately, positive values wait that many seconds.

Link copied to clipboard
suspend fun start(project: String, service: String, includeOneOff: Boolean = false): Result<ComposeOperationReport, ErrorResponse>

Start existing regular replicas of one service. See the service-set overload.

suspend fun start(project: String, services: Set<String>? = null, includeOneOff: Boolean = false): Result<ComposeOperationReport, ErrorResponse>

Start existing containers selected by exact project and service labels. Null services selects the whole project; an empty set makes no Docker requests. By default only confirmed regular replicas are included; includeOneOff also includes one-off containers and containers with unknown one-off metadata. Discovery completes before mutations. Requests run sequentially in snapshot order, continuing after HTTP errors and preserving each SDK result in the returned report. Start/stop accept HTTP 304 (already in the requested state) as success. An outer success means the batch completed, not that every container succeeded. Missing projects/services produce an empty report. No resources are created or removed. Transport/decoding failures and cancellation propagate, stopping subsequent requests; already applied changes remain and a failed request may have reached Docker. No dependency ordering, readiness checks, retries or rollback are provided.

Link copied to clipboard
suspend fun stop(project: String, service: String, includeOneOff: Boolean = false, timeoutSeconds: Int? = null): Result<ComposeOperationReport, ErrorResponse>

Stop existing regular replicas of one service. See the service-set overload.

suspend fun stop(project: String, services: Set<String>? = null, includeOneOff: Boolean = false, timeoutSeconds: Int? = null): Result<ComposeOperationReport, ErrorResponse>

Stop existing containers selected by exact project and service labels. Null services selects the whole project; an empty set makes no Docker requests. By default only confirmed regular replicas are included; includeOneOff also includes one-off containers and containers with unknown one-off metadata. Discovery completes before mutations. Requests run sequentially in snapshot order, continuing after HTTP errors and preserving each SDK result in the returned report. Start/stop accept HTTP 304 (already in the requested state) as success. An outer success means the batch completed, not that every container succeeded. Missing projects/services produce an empty report. No resources are created or removed. Transport/decoding failures and cancellation propagate, stopping subsequent requests; already applied changes remain and a failed request may have reached Docker. No dependency ordering, readiness checks, retries or rollback are provided. timeoutSeconds is the per-container stop grace period: null uses Docker defaults, -1 waits indefinitely, 0 kills immediately, positive values wait that many seconds.