exec Create
Creates an exec instance in a running container without starting its command. Pass the returned ID to Exec.startInteractive or Exec.startAndForget.
Return
Exec instance ID for Exec.startInteractive or Exec.startAndForget; creating it does not run the command.
Parameters
id
Container ID or name.
config
Command arguments, working directory, user and stdin/stdout/stderr attachment flags. For an interactive shell, enable stdin/stdout/stderr attachment and use the same tty value at start.
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()
}
}
}Content copied to clipboard