get Logs
suspend fun getLogs(id: String, parameters: ContainerLogsParameters = ContainerLogsParameters()): Result<Flow<LogLine>, ErrorResponse>
Inspects the container immediately to determine TTY framing, then returns a cold flow. The log request opens during collection. HTTP errors then throw dev.limebeck.libs.docker.client.model.DockerApiException; transport, decoding and collector failures propagate. Cancellation or completion releases the request. Follow mode has no implicit timeout; the caller owns its deadline and resubscription policy.
Return
Prepared flow or an error encountered before collection; see collection failure semantics above.
Parameters
id
Container ID or name.
parameters
Log streams, history bounds and follow mode; see ContainerLogsParameters for units/defaults.
Samples
try {
withTimeoutOrNull(30_000) {
coroutineScope {
launch {
docker.containers.getLogs(id, ContainerLogsParameters(
follow = true, stdout = true, stderr = true,
)).getOrThrow().collect { println("${it.type}: ${it.line}") }
}
launch {
docker.containers.getStats(id).getOrThrow().collect {
println(it.memoryStats)
}
}
launch {
docker.system.events(filters = mapOf("container" to listOf(id)))
.collect { println(it) }
}
}
}
} catch (failure: DockerApiException) {
println("HTTP ${failure.status.value}: ${failure.error.message}")
throw failure
}Content copied to clipboard