Skip to content

Commit 254ed23

Browse files
authored
Merge pull request #2611 from unraid/codex/7.2-filter-docker-ghost-containers
fix(docker): filter ghost containers from WebGUI
2 parents 2ac392d + 77554d8 commit 254ed23

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

emhttp/plugins/dynamix.docker.manager/include/DockerClient.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,11 +960,22 @@ public function getDockerContainers() {
960960
if (is_array($this::$containersCache)) return $this::$containersCache;
961961
$this::$containersCache = [];
962962
foreach ($this->getDockerJSON("/containers/json?all=1") as $ct) {
963+
if (!is_array($ct) || empty($ct['Id'])) {
964+
continue;
965+
}
966+
// Docker can leave stale "dead" entries after shutdown races; filter them from the UI list.
967+
if (($ct['State'] ?? '') === 'dead' || stripos($ct['Status'] ?? '', 'dead') === 0) {
968+
continue;
969+
}
963970
$info = $this->getContainerDetails($ct['Id']);
971+
// If inspect fails for a stale entry, skip it from the UI list.
972+
if (empty($info) || !is_array($info) || !empty($info['message']) || empty($info['Config']) || empty($info['State'])) {
973+
continue;
974+
}
964975
$c = [];
965976
$c['Image'] = DockerUtil::ensureImageTag($info['Config']['Image']);
966977
$c['ImageId'] = $this->extractID($ct['ImageID']);
967-
$c['Name'] = substr($info['Name'], 1);
978+
$c['Name'] = ltrim(($info['Name'] ?? $ct['Names'][0] ?? ''), '/');
968979
$c['Status'] = $ct['Status'] ?: 'None';
969980
$c['Running'] = $info['State']['Running'];
970981
$c['Paused'] = $info['State']['Paused'];

0 commit comments

Comments
 (0)