ExecSession

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

Link copied to clipboard
constructor(incomingFlow: Flow<LogLine>, isTty: Boolean, connection: DockerRawConnection)

Compatibility constructor for a caller-provided text flow. Its chunks contain re-encoded text.

Properties

Link copied to clipboard

Raw transport. Reading it directly bypasses buffered handshake data and output framing.

Link copied to clipboard
val incoming: Flow<LogLine>

Compatibility output: TTY text waits for line endings. Use incomingChunks for terminals.

Link copied to clipboard

Binary output, with Docker multiplex headers removed. Collect only once, or use incoming.

Link copied to clipboard

Whether output uses raw TTY bytes instead of Docker stdout/stderr multiplex framing.

Functions

Link copied to clipboard
open override fun close()

Closes the owned raw connection. Repeated calls are safe; subsequent sends or output collection fail.

Link copied to clipboard
suspend fun send(bytes: ByteArray)

Writes and flushes terminal input bytes without adding a newline.

suspend fun send(text: String)

Encodes text as UTF-8 and sends it without adding a newline.

Link copied to clipboard
open override fun toString(): String