diff --git a/app/Actions/Server/CleanupDocker.php b/app/Actions/Server/CleanupDocker.php index 1261e6830..3a0359c69 100644 --- a/app/Actions/Server/CleanupDocker.php +++ b/app/Actions/Server/CleanupDocker.php @@ -11,6 +11,8 @@ class CleanupDocker public function handle(Server $server, bool $force = true) { + + // cleanup docker images, containers, and builder caches if ($force) { instant_remote_process(['docker image prune -af'], $server, false); instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false); @@ -20,5 +22,15 @@ public function handle(Server $server, bool $force = true) instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false); instant_remote_process(['docker builder prune -f'], $server, false); } + // cleanup networks + $networks = collectDockerNetworksByServer($server); + $proxyNetworks = collectProxyDockerNetworksByServer($server); + $diff = $proxyNetworks->diff($networks); + if ($diff->count() > 0) { + $diff->map(function ($network) use ($server) { + instant_remote_process(["docker network disconnect $network coolify-proxy"], $server); + instant_remote_process(["docker network rm $network"], $server); + }); + } } }