execCreate($container, $cmd)->then(function ($info) use ($client) { echo 'Created with info: ' . json_encode($info) . PHP_EOL; return $client->execInspect($info['Id']); })->then(function ($info) use ($client) { echo 'Inspected after creation: ' . json_encode($info, JSON_PRETTY_PRINT) . PHP_EOL; return $client->execStart($info['ID'])->then(function ($out) use ($client, $info) { echo 'Starting returned: '; var_dump($out); return $client->execInspect($info['ID']); }); })->then(function ($info) { echo 'Inspected after execution: ' . json_encode($info, JSON_PRETTY_PRINT) . PHP_EOL; }, function (Exception $e) { echo 'ERROR: ' . $e->getMessage() . PHP_EOL; if ($e instanceof ResponseException) { echo 'Response: ' . $e->getResponse()->getBody() . PHP_EOL; } }); $loop->run();