$cpu1"; if ($cpu2) $row2[] = ""; } if ($c) echo '
'; echo ""._('CPU').":".implode($row1); if ($row2) echo "
"._('HT').":".implode($row2); } } # ██████╗ ██████╗ ██████╗ ███████╗ # ██╔════╝██╔═══██╗██╔══██╗██╔════╝ # ██║ ██║ ██║██║ ██║█████╗ # ██║ ██║ ██║██║ ██║██╔══╝ # ╚██████╗╚██████╔╝██████╔╝███████╗ # ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ########################## ## CREATE CONTAINER ## ########################## if (isset($_POST['contName'])) { $postXML = postToXML($_POST, true); $dry_run = isset($_POST['dryRun']) && $_POST['dryRun']=='true'; $existing = _var($_POST,'existingContainer',false); $create_paths = $dry_run ? false : true; // Get the command line [$cmd, $Name, $Repository] = xmlToCommand($postXML, $create_paths); readfile("$docroot/plugins/dynamix.docker.manager/log.htm"); @flush(); // Saving the generated configuration file. $userTmplDir = $dockerManPaths['templates-user']; if (!is_dir($userTmplDir)) mkdir($userTmplDir, 0777, true); if ($Name) { $filename = sprintf('%s/my-%s.xml', $userTmplDir, $Name); if (is_file($filename)) { $oldXML = simplexml_load_file($filename); if ($oldXML->Icon != $_POST['contIcon']) { if (!strpos($Repository,":")) $Repository .= ":latest"; $iconPath = $DockerTemplates->getIcon($Repository,$Name); @unlink("$docroot/$iconPath"); @unlink("{$dockerManPaths['images']}/".basename($iconPath)); } } file_put_contents($filename, $postXML); } // Run dry if ($dry_run) { echo "

XML

"; echo "
".htmlspecialchars($postXML)."
"; echo "

COMMAND:

"; echo "
".htmlspecialchars($cmd)."
"; echo "
"; echo "

"; goto END; } // Will only pull image if it's absent if (!$DockerClient->doesImageExist($Repository)) { // Pull image if (!pullImage($Name, $Repository)) { echo '

'; goto END; } } $startContainer = true; // Remove existing container if ($DockerClient->doesContainerExist($Name)) { // attempt graceful stop of container first $oldContainerInfo = $DockerClient->getContainerDetails($Name); if (!empty($oldContainerInfo) && !empty($oldContainerInfo['State']) && !empty($oldContainerInfo['State']['Running'])) { // attempt graceful stop of container first stopContainer($Name); } // force kill container if still running after 10 seconds removeContainer($Name); } // Remove old container if renamed if ($existing && $DockerClient->doesContainerExist($existing)) { // determine if the container is still running $oldContainerInfo = $DockerClient->getContainerDetails($existing); if (!empty($oldContainerInfo) && !empty($oldContainerInfo['State']) && !empty($oldContainerInfo['State']['Running'])) { // attempt graceful stop of container first stopContainer($existing); } else { // old container was stopped already, ensure newly created container doesn't start up automatically $startContainer = false; } // force kill container if still running after 10 seconds removeContainer($existing,1); // remove old template if (strtolower($filename) != strtolower("$userTmplDir/my-$existing.xml")) { @unlink("$userTmplDir/my-$existing.xml"); } } if ($startContainer) $cmd = str_replace('/docker create ', '/docker run -d ', $cmd); execCommand($cmd); if ($startContainer) addRoute($Name); // add route for remote WireGuard access echo '

'; goto END; } ########################## ## UPDATE CONTAINER ## ########################## if (isset($_GET['updateContainer'])){ $echo = empty($_GET['mute']); if ($echo) { readfile("$docroot/plugins/dynamix.docker.manager/log.htm"); @flush(); } foreach ($_GET['ct'] as $value) { $tmpl = $DockerTemplates->getUserTemplate(unscript(urldecode($value))); if ($echo && !$tmpl) { echo ""; @flush(); continue; } $xml = file_get_contents($tmpl); [$cmd, $Name, $Repository] = xmlToCommand($tmpl); $Registry = getXmlVal($xml, "Registry"); $oldImageID = $DockerClient->getImageID($Repository); // pull image if ($echo && !pullImage($Name, $Repository)) continue; $oldContainerInfo = $DockerClient->getContainerDetails($Name); // determine if the container is still running $startContainer = false; if (!empty($oldContainerInfo) && !empty($oldContainerInfo['State']) && !empty($oldContainerInfo['State']['Running'])) { // since container was already running, put it back it to a running state after update $cmd = str_replace('/docker create ', '/docker run -d ', $cmd); $startContainer = true; // attempt graceful stop of container first stopContainer($Name, false, $echo); } // force kill container if still running after time-out if (empty($_GET['communityApplications'])) removeContainer($Name, $echo); execCommand($cmd, $echo); if ($startContainer) addRoute($Name); // add route for remote WireGuard access $DockerClient->flushCaches(); $newImageID = $DockerClient->getImageID($Repository); // remove old orphan image since it's no longer used by this container if ($oldImageID && $oldImageID != $newImageID) removeImage($oldImageID, $echo); } echo '

'; goto END; } ######################### ## REMOVE TEMPLATE ## ######################### if (isset($_POST['rmTemplate'])) { if (file_exists($_POST['rmTemplate']) && dirname($_POST['rmTemplate'])==$dockerManPaths['templates-user']) unlink($_POST['rmTemplate']); } ######################### ## LOAD TEMPLATE ## ######################### $xmlType = $xmlTemplate = ''; if (isset($_GET['xmlTemplate'])) { [$xmlType, $xmlTemplate] = my_explode(':', unscript(urldecode($_GET['xmlTemplate']))); if (is_file($xmlTemplate)) { $xml = xmlToVar($xmlTemplate); $templateName = $xml['Name']; if ($xmlType == 'default') { if (!empty($dockercfg['DOCKER_APP_CONFIG_PATH']) && file_exists($dockercfg['DOCKER_APP_CONFIG_PATH'])) { // override /config foreach ($xml['Config'] as &$arrConfig) { if ($arrConfig['Type'] == 'Path' && strtolower($arrConfig['Target']) == '/config') { $arrConfig['Default'] = $arrConfig['Value'] = realpath($dockercfg['DOCKER_APP_CONFIG_PATH']).'/'.$xml['Name']; if (empty($arrConfig['Display']) || preg_match("/^Host Path\s\d/", $arrConfig['Name'])) { $arrConfig['Display'] = 'advanced-hide'; } if (empty($arrConfig['Name']) || preg_match("/^Host Path\s\d/", $arrConfig['Name'])) { $arrConfig['Name'] = 'AppData Config Path'; } } $arrConfig['Name'] = strip_tags(_var($arrConfig,'Name')); $arrConfig['Description'] = strip_tags(_var($arrConfig,'Description')); $arrConfig['Requires'] = strip_tags(_var($arrConfig,'Requires')); } } if (!empty($dockercfg['DOCKER_APP_UNRAID_PATH']) && file_exists($dockercfg['DOCKER_APP_UNRAID_PATH'])) { // override /unraid $boolFound = false; foreach ($xml['Config'] as &$arrConfig) { if ($arrConfig['Type'] == 'Path' && strtolower($arrConfig['Target']) == '/unraid') { $arrConfig['Default'] = $arrConfig['Value'] = realpath($dockercfg['DOCKER_APP_UNRAID_PATH']); $arrConfig['Display'] = 'hidden'; $arrConfig['Name'] = 'Unraid Share Path'; $boolFound = true; } } if (!$boolFound) { $xml['Config'][] = [ 'Name' => 'Unraid Share Path', 'Target' => '/unraid', 'Default' => realpath($dockercfg['DOCKER_APP_UNRAID_PATH']), 'Value' => realpath($dockercfg['DOCKER_APP_UNRAID_PATH']), 'Mode' => 'rw', 'Description' => '', 'Type' => 'Path', 'Display' => 'hidden', 'Required' => 'false', 'Mask' => 'false' ]; } } } $xml['Overview'] = str_replace(['[', ']'], ['<', '>'], $xml['Overview']); $xml['Description'] = $xml['Overview'] = strip_tags(str_replace("
","\n", $xml['Overview'])); echo ""; } } echo ""; $authoringMode = $dockercfg['DOCKER_AUTHORING_MODE'] == "yes" ? true : false; $authoring = $authoringMode ? 'advanced' : 'noshow'; $disableEdit = $authoringMode ? 'false' : 'true'; $showAdditionalInfo = ''; $bgcolor = strstr('white,azure',$display['theme']) ? '#f2f2f2' : '#1c1c1c'; ?> "> "> "> ">
doesContainerExist($templateName)):?>
_(Template)_: : :docker_client_general_help:
_(Name)_: : :docker_client_name_help:
_(Overview)_: :
_(Overview)_: : :docker_client_overview_help:
_(Additional Requirements)_: :
_(Additional Requirements)_: : :docker_client_additional_requirements_help:
_(Repository)_: : :docker_client_repository_help:
_(Categories)_: : _(Support Thread)_: : :docker_client_support_thread_help: _(Project Page)_: : :docker_client_project_page_help: _(Read Me First)_: : :docker_client_readme_help:
_(Registry URL)_: : :docker_client_hub_url_help:
Donation Text: : Donation Link: : Template URL: :
_(Icon URL)_: : :docker_client_icon_url_help: _(WebUI)_: : :docker_client_webui_help: _(Extra Parameters)_: : :docker_extra_parameters_help: _(Post Arguments)_: : :docker_post_arguments_help: _(CPU Pinning)_: : :docker_cpu_pinning_help:
_(Network Type)_: :
_(Fixed IP address)_ (_(optional)_): : :docker_fixed_ip_help:
_(Console shell command)_: : _(Privileged)_: : :docker_privileged_help:
  : _(Show more settings)_ ...   : _(Show docker allocations)_ ...   : _(Add another Path, Port, Variable, Label or Device)_   : ">