{"record":{"id":"fad3ac488519c5e9","repo":"coollabsio/coolify","slug":"scheduledtaskjob-failed-no-valid-container-was-fo","errorCode":null,"errorMessage":"ScheduledTaskJob failed: No valid container was found. Is the container name correct?","messagePattern":"ScheduledTaskJob failed: No valid container was found\\. Is the container name correct\\?","errorType":"exception","errorClass":"NonReportableException","httpStatus":null,"severity":"error","filePath":"app/Jobs/ScheduledTaskJob.php","lineNumber":167,"sourceCode":"                if (count($this->containers) == 1 || str_starts_with($containerName, $this->task->container.'-'.$this->resource->uuid)) {\n                    $cmd = \"sh -c '\".str_replace(\"'\", \"'\\''\", $this->task->command).\"'\";\n                    $exec = \"docker exec {$containerName} {$cmd}\";\n                    // Disable SSH multiplexing to prevent race conditions when multiple tasks run concurrently\n                    // See: https://github.com/coollabsio/coolify/issues/6736\n                    $this->task_output = instant_remote_process([$exec], $this->server, true, false, $this->timeout, disableMultiplexing: true);\n                    $this->task_log->update([\n                        'status' => 'success',\n                        'message' => $this->task_output,\n                    ]);\n\n                    $this->team?->notify(new TaskSuccess($this->task, $this->task_output));\n\n                    return;\n                }\n            }\n\n            // No valid container was found.\n            throw new NonReportableException('ScheduledTaskJob failed: No valid container was found. Is the container name correct?');\n        } catch (\\Throwable $e) {\n            if ($this->task_log) {\n                $this->task_log->update([\n                    'status' => 'failed',\n                    'message' => $this->task_output ?? $e->getMessage(),\n                ]);\n            }\n\n            // Log the error to the scheduled-errors channel\n            Log::channel('scheduled-errors')->error('ScheduledTask execution failed', [\n                'job' => 'ScheduledTaskJob',\n                'task_id' => $this->task->uuid,\n                'task_name' => $this->task->name,\n                'server' => $this->server?->name ?? 'unknown',\n                'attempt' => $this->attempts(),\n                'error' => $e->getMessage(),\n            ]);\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/coollabsio/coolify/blob/70b9acc42467278373e00de77abb40684e25b395/app/Jobs/ScheduledTaskJob.php#L149-L185","documentation":"ScheduledTaskJob collects the resource's running containers (applications via getCurrentApplicationContainerStatus, services via running applications+databases), then executes only in a container whose name starts with '{task->container}-{resource->uuid}'. If the loop completes without a match — multiple containers and a non-matching stored name — it throws NonReportableException so the ScheduledTaskExecution row is marked failed and the scheduled-errors channel is notified without flagging an app bug.","triggerScenarios":"Scheduled task on a multi-container application or service where task->container does not prefix-match any running container name; the compose service was renamed after the task was created; only a subset of containers running so the named one is missing from the list.","commonSituations":"Renaming a service in docker-compose and forgetting the scheduled task; task created against one container, later more services added; entering the full container name (with -uuid) into the task's container field, which can never prefix-match.","solutions":["Edit the scheduled task and set 'Container' to the bare service name shown on the resource's container list (the part before '-uuid').","Verify with docker ps on the server that the container is running — stopped containers are excluded from the candidate list.","If the resource now has exactly one container, clear the container field so the single-container shortcut applies."],"exampleFix":"// before: full container name stored — never prefix-matches\n$task->container = 'myapp-' . $resource->uuid;\n$task->save();\n\n// after: bare service name; the job appends '-{resource->uuid}' itself\n$task->container = 'myapp';\n$task->save();","handlingStrategy":"validation","validationCode":"// Before dispatching ScheduledTaskJob, verify the target exists\n$containers = $resource->type() === 'application'\n    ? getCurrentApplicationContainerStatus($server, $resource->id, 0)->pluck('Names')\n    : $resource->applications()->get()\n        ->concat($resource->databases()->get())\n        ->filter(fn ($c) => str(data_get($c, 'status'))->contains('running'))\n        ->map(fn ($c) => data_get($c, 'name') . '-' . $resource->uuid);\n$prefix = ($task->container ?? '') . '-' . $resource->uuid;\n$valid = $containers->count() === 1 || $containers->contains(fn ($n) => str_starts_with($n, $prefix));\nif (! $valid) { /* flag task as misconfigured before it ever runs */ }","typeGuard":null,"tryCatchPattern":"catch (NonReportableException $e) { record on the ScheduledTaskExecution log and notify the task owner with the container list — this is a config error, retrying identical input cannot succeed. }","preventionTips":["Store bare service names in task->container; never the full '-uuid' container name.","When renaming compose services, update scheduled tasks in the same change.","Periodically reconcile task container fields against actually running containers."],"tags":["scheduled-tasks","docker","container-resolution","coolify"],"backgroundTag":"container-not-found","analyzedSha":"70b9acc42467278373e00de77abb40684e25b395","analyzedAt":"2026-08-17T01:41:01.313Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}