@@ -911,23 +911,53 @@ public function execCreate($container, $config)
911911 * for bigger command outputs, it's usually a better idea to use a streaming
912912 * approach, see `execStartStream()` for more details.
913913 *
914- * If detach is true, this API returns after starting the exec command.
915- * Otherwise, this API sets up an interactive session with the exec command.
916- *
917- * @param string $exec exec ID
918- * @param array $config (see link)
914+ * @param string $exec exec ID
915+ * @param boolean $tty tty mode
919916 * @return PromiseInterface Promise<string> buffered exec data
920917 * @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#exec-start
921918 * @uses self::execStartStream()
922919 * @see self::execStartStream()
920+ * @see self::execStartDetached()
923921 */
924- public function execStart ($ exec , $ config = array () )
922+ public function execStart ($ exec , $ tty = false )
925923 {
926924 return $ this ->streamingParser ->bufferedStream (
927- $ this ->execStartStream ($ exec , $ config )
925+ $ this ->execStartStream ($ exec , $ tty )
928926 );
929927 }
930928
929+ /**
930+ * Starts a previously set up exec instance id.
931+ *
932+ * This resolves after starting the exec command, but without waiting for
933+ * the command output (detached mode).
934+ *
935+ * @param string $exec exec ID
936+ * @param boolean $tty tty mode
937+ * @return PromiseInterface Promise<null>
938+ * @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#exec-start
939+ * @see self::execStart()
940+ * @see self::execStartStream()
941+ */
942+ public function execStartDetached ($ exec , $ tty = false )
943+ {
944+ return $ this ->browser ->post (
945+ $ this ->uri ->expand (
946+ '/exec/{exec}/start ' ,
947+ array (
948+ 'exec ' => $ exec
949+ )
950+ ),
951+ array (
952+ 'Content-Type ' => 'application/json '
953+ ),
954+ $ this ->json (array (
955+ 'Detach ' => true ,
956+ 'Tty ' => !!$ tty
957+ ))
958+ )->then (array ($ this ->parser , 'expectEmpty ' ));
959+ }
960+
931961 /**
932962 * Starts a previously set up exec instance id.
933963 *
@@ -938,16 +968,14 @@ public function execStart($exec, $config = array())
938968 * This works for command output of any size as only small chunks have to
939969 * be kept in memory.
940970 *
941- * If detach is true, this API returns after starting the exec command.
942- * Otherwise, this API sets up an interactive session with the exec command.
943- *
944- * @param string $exec exec ID
945- * @param array $config (see link)
971+ * @param string $exec exec ID
972+ * @param boolean $tty tty mode
946973 * @return ReadableStreamInterface stream of exec data
947974 * @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#exec-start
948975 * @see self::execStart()
976+ * @see self::execStartDetached()
949977 */
950- public function execStartStream ($ exec , $ config = array () )
978+ public function execStartStream ($ exec , $ tty = false )
951979 {
952980 return $ this ->streamingParser ->parsePlainStream (
953981 $ this ->browser ->withOptions (array ('streaming ' => true ))->post (
@@ -960,7 +988,9 @@ public function execStartStream($exec, $config = array())
960988 array (
961989 'Content-Type ' => 'application/json '
962990 ),
963- $ this ->json ($ config )
991+ $ this ->json (array (
992+ 'Tty ' => !!$ tty
993+ ))
964994 )
965995 );
966996 }
0 commit comments