diff --git a/plugins/dynamix.docker.manager/DockerContainers.page b/plugins/dynamix.docker.manager/DockerContainers.page index ffc415b4e..7efa73f88 100644 --- a/plugins/dynamix.docker.manager/DockerContainers.page +++ b/plugins/dynamix.docker.manager/DockerContainers.page @@ -22,7 +22,6 @@ $DockerClient = new DockerClient(); $DockerUpdate = new DockerUpdate(); $DockerTemplates = new DockerTemplates(); ?> - diff --git a/plugins/dynamix.docker.manager/include/CreateDocker.php b/plugins/dynamix.docker.manager/include/CreateDocker.php index 1b14eba53..0a405a821 100644 --- a/plugins/dynamix.docker.manager/include/CreateDocker.php +++ b/plugins/dynamix.docker.manager/include/CreateDocker.php @@ -326,7 +326,7 @@ function xmlToVar($xml) { return $out; } -function xmlToCommand($xml) { +function xmlToCommand($xml, $create_paths=false) { global $var; $xml = xmlToVar($xml); $cmdName = (strlen($xml['Name'])) ? '--name="'.$xml['Name'].'"' : ""; @@ -349,10 +349,20 @@ function xmlToCommand($xml) { if (!strlen($containerConfig)) continue; if ($confType == "path") { $Volumes[] = sprintf('"%s":"%s":%s', $hostConfig, $containerConfig, $Mode); + if ( ! file_exists($hostConfig) && $create_paths ) { + @mkdir($hostConfig, 0777, true); + @chown($hostConfig, 99); + @chgrp($hostConfig, 100); + } } elseif ($confType == 'port') { - $Ports[] = sprintf("%s:%s/%s", $hostConfig, $containerConfig, $Mode); + # Export ports as variable if Network is set to host + if (strtolower($xml['Network']) == 'host') { + $Variables[] = strtoupper(sprintf('"%s_PORT_%s"="%s"', $Mode, $containerConfig, $hostConfig)); + } else { + $Ports[] = sprintf("%s:%s/%s", $hostConfig, $containerConfig, $Mode); + } } elseif ($confType == "variable") { - $Variables[] = sprintf('%s="%s"', $containerConfig, $hostConfig); + $Variables[] = sprintf('"%s"="%s"', $containerConfig, $hostConfig); } elseif ($confType == "device") { $Devices[] = '"'.$containerConfig.'"'; } @@ -410,12 +420,14 @@ function setXmlVal(&$xml, $value, $el, $attr = null, $pos = 0) { if (isset($_POST['contName'])) { $postXML = postToXML($_POST, true); + $dry_run = ($_POST['dryRun'] == "true") ? true : false; + $create_paths = $dry_run ? false : true; // Get the command line - list($cmd, $Name, $Repository) = xmlToCommand($postXML); + list($cmd, $Name, $Repository) = xmlToCommand($postXML, $create_paths); // Run dry - if ($_POST['dryRun'] == "true") { + if ($dry_run) { echo "
".htmlentities($postXML).""; echo "