Skip to content

Commit 20404c4

Browse files
committed
Documentation for TTY mode
1 parent 1166aa4 commit 20404c4

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ $stream->on('close', function () {
223223

224224
See also the [streaming exec example](examples/exec-stream.php) and the [exec benchmark example](examples/benchmark-exec.php).
225225

226+
The TTY mode should be set depending on whether your command needs a TTY
227+
or not. Note that toggling the TTY mode affects how/whether you can access
228+
the STDERR stream and also has a significant impact on performance for
229+
larger streams (relevant for 100 MiB and above). See also the TTY mode
230+
on the `execStart*()` call.
231+
226232
Running this benchmark on my personal (rather mediocre) VM setup reveals that
227233
the benchmark achieves a throughput of ~300 MiB/s while the (totally unfair)
228234
comparison script using the plain Docker client only yields ~100 MiB/s.

src/Client.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,24 @@ public function imageSearch($term)
882882
/**
883883
* Sets up an exec instance in a running container id
884884
*
885+
* The TTY mode should be set depending on whether your command needs a TTY
886+
* or not. Note that toggling the TTY mode affects how/whether you can access
887+
* the STDERR stream and also has a significant impact on performance for
888+
* larger streams (relevant for 100 MiB and above). See also the TTY mode
889+
* on the `execStart*()` call:
890+
* - create=false, start=false:
891+
* STDOUT/STDERR are multiplexed into separate streams + quite fast.
892+
* This is the default mode, also for `docker exec`.
893+
* - create=true, start=true:
894+
* STDOUT and STDERR are mixed into a single stream + relatively slow.
895+
* This is how `docker exec -t` works internally.
896+
* - create=false, start=true
897+
* STDOUT is streamed, STDERR can not be accessed at all + fastest mode.
898+
* This looks strange to you? It probably is. See also the benchmarking example.
899+
* - create=true, start=false
900+
* STDOUT/STDERR are multiplexed into separate streams + relatively slow
901+
* This looks strange to you? It probably is. Consider using the first option instead.
902+
*
885903
* @param string $container container ID
886904
* @param string $cmd Command to run specified as an array of strings
887905
* @param boolean $tty TTY mode

0 commit comments

Comments
 (0)