events

fun events(since: String? = null, until: String? = null, filters: Map<String, List<String>>? = null): Flow<EventMessage>

Returns a cold event flow: each collection opens a separate request. HTTP errors throw dev.limebeck.libs.docker.client.model.DockerApiException. Malformed JSON events are skipped; transport and collector failures propagate. Cancellation or completion releases the request. There is no automatic reconnect. Docker history is finite: save a cursor, deduplicate replay and refresh resource state after reconnect. An interrupted connection may also finish as normal EOF.

Return

Cold flow of daemon events; failures are reported during collection.

Parameters

since

Unix timestamp in seconds (optionally fractional), or an RFC 3339 timestamp; null requests new events only.

until

End timestamp in the same format as since; null leaves the subscription live.

filters

For example mapOf("type" to listOf("container"), "event" to listOf("start", "die")); encoded as JSON.

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
}