get Stats
suspend fun getStats(id: String, stream: Boolean = true, oneShot: Boolean = false): Result<Flow<ContainerStatsResponse>, ErrorResponse>
With stream=true, returns a cold flow whose HTTP request opens on collection. HTTP errors during collection throw dev.limebeck.libs.docker.client.model.DockerApiException; malformed samples fail collection. With stream=false, performs the request now and wraps a successful sample in a one-element flow. Cancellation releases the streaming request. CPU percentages require successive counter samples.
Return
Prepared flow or an error encountered before collection; see collection failure semantics above.
Parameters
id
Container ID or name.
stream
Use a live cold flow when true; fetch a single response immediately when false.
one Shot
Request one sample without waiting for a second CPU sample; used with stream=false.
Samples
val sample = docker.containers.getStats(id, stream = false, oneShot = true)
.getOrThrow().first()
println(sample.memoryStats)Content copied to clipboard