OK' : 'Error: ' . $response['msg'] . ''; if ($response['type'] == "success") { break; } usleep(1500000); $retry++; } echo (!isset($last_response)) ? 'Already running' : $last_response; } if ($_GET['action'] == "stop") { header('Content-Type: text/html; charset=utf-8'); $retry = 0; while (docker('info', $_GET['service'])['State']['Running'] == 1 && $retry <= 3) { $response = docker('post', $_GET['service'], 'stop'); $response = json_decode($response, true); $last_response = ($response['type'] == "success") ? 'OK' : 'Error: ' . $response['msg'] . ''; if ($response['type'] == "success") { break; } usleep(1500000); $retry++; } echo (!isset($last_response)) ? 'Not running' : $last_response; } if ($_GET['action'] == "restart") { header('Content-Type: text/html; charset=utf-8'); $response = docker('post', $_GET['service'], 'restart'); $response = json_decode($response, true); $last_response = ($response['type'] == "success") ? 'OK' : 'Error: ' . $response['msg'] . ''; echo (!isset($last_response)) ? 'Cannot restart container' : $last_response; } if ($_GET['action'] == "logs") { $lines = (empty($_GET['lines']) || !is_numeric($_GET['lines'])) ? 1000 : $_GET['lines']; header('Content-Type: text/plain; charset=utf-8'); print_r(preg_split('/\n/', docker('logs', $_GET['service'], $lines))); } } ?>