server->id) ->whereIn('status', [ ApplicationDeploymentStatus::IN_PROGRESS->value, ApplicationDeploymentStatus::QUEUED->value, ]) ->pluck('deployment_uuid') ->toArray(); $containers = instant_remote_process_with_timeout(['docker container ps --format \'{{json .}}\' | jq -s \'map(select(.Image | contains("'.config('constants.coolify.registry_url').'/coollabsio/coolify-helper")))\''], $this->server, false); $helperContainers = collect(json_decode($containers)); if ($helperContainers->count() > 0) { foreach ($helperContainers as $container) { $containerId = data_get($container, 'ID'); $containerName = data_get($container, 'Names'); // Check if this container belongs to an active deployment $isActiveDeployment = false; foreach ($activeDeployments as $deploymentUuid) { if (str_contains($containerName, $deploymentUuid)) { $isActiveDeployment = true; break; } } if ($isActiveDeployment) { continue; } instant_remote_process_with_timeout(['docker container rm -f '.$containerId], $this->server, false); } } } catch (\Throwable $e) { send_internal_notification('CleanupHelperContainersJob failed with error: '.$e->getMessage()); } } }