If you remove the starting "#" on the third line, it will start any stopped containers (and stop them after getting their size)
#!/usr/bin/php
<?PHP
#$startStopped = true;
require_once("/usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php");
$DockerClient = new DockerClient();
$DockerTemplates = new DockerTemplates();
$info = getRunningContainers();
foreach ($info as $contName=>$cont) {
if ( $startStopped && ! $cont['running'] ) {
$DockerClient->startContainer($cont['Id']);
}
if ( $cont['running'] || $startStopped ) {
echo "$contName Size: ".rtrim(exec("docker exec $contName du -shx /"),"/")." Logs: ";
echo human_filesize(exec("docker logs $contName 2>&1 | wc -c"),1)."\n";
}
if ( ! $cont['running'] && $startStopped ) {
$DockerClient->stopContainer($cont['Id']);
}
}
function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
function getRunningContainers() {
global $DockerClient, $DockerTemplates;
$containers = $DockerClient->getDockerContainers();
$info = $DockerTemplates->getAllInfo();
foreach ($containers as $container) {
$info[$container['Name']]['running'] = $container['Running'];
$info[$container['Name']]['Id'] = $container['Id'];
$infoTmp[$container['Name']] = $info[$container['Name']];
}
return $infoTmp ?: array();
}
?>