Exec Session
Owned duplex exec/attach connection, independent of the client's HTTP connection pool.
Collect exactly one of incomingChunks or incoming, once. Completion, cancellation or failure of that collection closes the connection. Close explicitly if output is never collected; use is supported. Closing a connection does not guarantee that Docker terminates the remote process. Read/write failures propagate with their original causes; SDK-created sessions attach dev.limebeck.libs.docker.client.diagnostics.dockerContext when available.
Samples
val execId = docker.containers.execCreate(containerId, ExecConfig(
cmd = listOf("/bin/sh"), tty = true,
attachStdin = true, attachStdout = true, attachStderr = true,
)).getOrThrow().id
docker.exec.startInteractive(execId, tty = true).getOrThrow().use { session ->
coroutineScope {
val sender = launch {
try { input.collect { session.send(it) } }
finally { session.close() }
}
try {
docker.exec.resize(execId, h = 24, w = 80).getOrThrow()
session.incomingChunks.collect { output(it.bytes) }
} finally {
sender.cancelAndJoin()
}
}
}Constructors
Properties
Raw transport. Reading it directly bypasses buffered handshake data and output framing.
Compatibility output: TTY text waits for line endings. Use incomingChunks for terminals.
Binary output, with Docker multiplex headers removed. Collect only once, or use incoming.