@@ -882,6 +882,10 @@ public function imageSearch($term)
882882 /**
883883 * Sets up an exec instance in a running container id
884884 *
885+ * The $command should be given as an array of strings (the command plus
886+ * arguments). Alternatively, you can also pass a single command line string
887+ * which will then be wrapped in a shell process.
888+ *
885889 * The TTY mode should be set depending on whether your command needs a TTY
886890 * or not. Note that toggling the TTY mode affects how/whether you can access
887891 * the STDERR stream and also has a significant impact on performance for
@@ -900,17 +904,21 @@ public function imageSearch($term)
900904 * STDOUT/STDERR are multiplexed into separate streams + relatively slow
901905 * This looks strange to you? It probably is. Consider using the first option instead.
902906 *
903- * @param string $container container ID
904- * @param string $cmd Command to run specified as an array of strings
905- * @param boolean $tty TTY mode
906- * @param boolean $stdin attaches to STDIN of the exec command
907- * @param boolean $stdout attaches to STDOUT of the exec command
908- * @param boolean $stderr attaches to STDERR of the exec command
907+ * @param string $container container ID
908+ * @param string|array $cmd Command to run specified as an array of strings or a single command string
909+ * @param boolean $tty TTY mode
910+ * @param boolean $stdin attaches to STDIN of the exec command
911+ * @param boolean $stdout attaches to STDOUT of the exec command
912+ * @param boolean $stderr attaches to STDERR of the exec command
909913 * @return PromiseInterface Promise<array> with exec ID in the form of `array("Id" => $execId)`
910914 * @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#exec-create
911915 */
912916 public function execCreate ($ container , $ cmd , $ tty = false , $ stdin = false , $ stdout = true , $ stderr = true )
913917 {
918+ if (!is_array ($ cmd )) {
919+ $ cmd = array ('sh ' , '-c ' , (string )$ cmd );
920+ }
921+
914922 return $ this ->postJson (
915923 $ this ->uri ->expand (
916924 '/containers/{container}/exec ' ,
0 commit comments