coollabsio/coolify · error · RuntimeException
Container not found.
Error message
Container not found.
What it means
After the format check passes, the component resolves the container via collect($this->containers)->firstWhere('container.Names', $this->selected_container). The $this->containers array is the list of Docker containers previously fetched for this resource's servers; a null match means the name is syntactically valid but no container in that allowed list carries it, so the terminal connection is refused with 'Container not found.'.
Solutions
- Reload the page (or re-trigger the container list load) and select the container again from the refreshed dropdown
- Verify the container actually runs on the target server: docker ps | grep <name>
- If the container exists but is missing from the list, check the resource's destination/server wiring so it is queried on the right host
- Re-run or restart the deployment so container names in the UI match Docker's current state
Example fix
// before
$this->dispatch('connectToContainer', container: $this->selected_container);
// after
$this->loadContainers(); // re-fetch current list from Docker
if (collect($this->containers)->firstWhere('container.Names', $this->selected_container)) {
$this->dispatch('connectToContainer', container: $this->selected_container);
} else {
$this->dispatch('error', 'Container no longer exists - pick a new one.');
} Defensive patterns
Strategy: validation
Validate before calling
$exists = collect($this->containers)
->firstWhere('container.Names', $this->selected_container) !== null;
if (! $exists) {
$this->dispatch('error', 'Container no longer exists.');
return;
} Type guard
/** @param mixed $value */
function isLiveContainerEntry($value): bool
{
return is_array($value)
&& data_get($value, 'server') instanceof \App\Models\Server
&& filled(data_get($value, 'container.Names'));
} Try / catch
Catch \RuntimeException in the action, dispatch('error', $e->getMessage()), and refresh the containers list so the dropdown self-heals instead of leaving stale options. Prevention
- Re-fetch the container list immediately before connecting rather than trusting the rendered snapshot
- Re-select the container after any deployment that recreates containers
- Verify with docker ps on the host when the UI insists a container is missing
When it happens
Trigger: The container was stopped, removed, or recreated with a new generated name between page render and clicking Connect (e.g. after a redeploy the app container now has a new hash suffix); the resource was moved to a different server/destination so the containers list no longer includes it; the containers property was never populated for this resource type; a replayed Livewire snapshot references an old name.
Common situations: Stale browser tab left open across a deployment; preview deployments that append PR/hash to container names; docker rm run manually on the host; scaling events that replace containers.
Related errors
- Invalid container name format
- Destination not found.
- Preview not found
- Command execution failed
- Destination not found.
AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17).
Data as JSON: /api/errors/61419b7576e9a384.
Report an issue: GitHub.
Appendix: source
Thrown at app/Livewire/Project/Shared/ExecuteContainerCommand.php:212
#[On('connectToContainer')]
public function connectToContainer()
{
if ($this->selected_container === 'default') {
$this->dispatch('error', 'Please select a container.');
return;
}
try {
$this->authorize('canAccessTerminal');
// Validate container name format
if (! ValidationPatterns::isValidContainerName($this->selected_container)) {
throw new \InvalidArgumentException('Invalid container name format');
}
// Verify container exists in our allowed list
$container = collect($this->containers)->firstWhere('container.Names', $this->selected_container);
if (is_null($container)) {
throw new \RuntimeException('Container not found.');
}
// Verify server ownership and status
$server = data_get($container, 'server');
if (! $server || ! $server instanceof Server) {
throw new \RuntimeException('Invalid server configuration.');
}
$this->authorize('view', $server);
if ($server->isForceDisabled()) {
throw new \RuntimeException('Server is disabled.');
}
// Additional ownership verification based on resource type
$resourceServer = match ($this->type) {
'application' => $this->resource->destination->server,
'database' => $this->resource->destination->server,View on GitHub (pinned to 70b9acc424)