+
+
+ No Swarm Services Found
+
+ Docker Swarm is active with {nodeCount} node(s), but
+ there are no application services running in the swarm.
+
+
+
+
+ This view shows containers deployed as Swarm services.
+ Standalone or Docker Compose containers won't appear here.
+
+
To see containers in this view, make sure your applications are:
+
+
+ Deployed as Swarm services — Applications in
+ Dokploy deploy to Swarm by default. Docker Compose projects need to
+ use{" "}
+ Stack{" "}
+ type (not{" "}
+
+ Docker Compose
+
+ ) to run as Swarm services.
+
+
+ Using a registry (for multi-node setups) —
+ Worker nodes need to pull images from a shared registry. Configure one
+ in{" "}
+
+ Cluster Settings
+
+ .
+
+
+ Successfully built and deployed — Check your
+ project's deployment logs for errors.
+
+ Containers are failing to start — check deployment logs for
+ errors
+
+
+ Images can't be pulled on worker nodes — verify your{" "}
+
+ registry configuration
+
+
+
+ Node constraints prevent scheduling — check placement rules in
+ your app's Cluster settings
+
+
+
+
+
+
+ );
+};
diff --git a/apps/dokploy/components/dashboard/swarm/containers/show-swarm-containers.tsx b/apps/dokploy/components/dashboard/swarm/containers/show-swarm-containers.tsx
index 169d888ba..4c4c5e2be 100644
--- a/apps/dokploy/components/dashboard/swarm/containers/show-swarm-containers.tsx
+++ b/apps/dokploy/components/dashboard/swarm/containers/show-swarm-containers.tsx
@@ -1,21 +1,24 @@
-import { useEffect, useState } from "react";
-import Link from "next/link";
import {
- AlertCircle,
AlertTriangle,
Container,
- Cpu,
- ExternalLink,
Info,
Loader2,
RefreshCw,
- Server,
} from "lucide-react";
+import Link from "next/link";
+import { useEffect, useState } from "react";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
+import { CardTitle } from "@/components/ui/card";
import { api } from "@/utils/api";
+import {
+ NoRunningContainers,
+ NoServices,
+ ServicesError,
+ SwarmNotAvailable,
+} from "./empty-states";
import { NodeSection } from "./node-section";
+import { SummaryCards } from "./summary-cards";
import type { ContainerInfo, ContainerStat, SwarmNode } from "./types";
interface Props {
@@ -25,7 +28,6 @@ interface Props {
export const ShowSwarmContainers = ({ serverId }: Props) => {
const [expandedNodes, setExpandedNodes] = useState>(new Set());
- // 1. Check if swarm is functioning by fetching nodes
const {
data: nodes,
isLoading: nodesLoading,
@@ -34,7 +36,6 @@ export const ShowSwarmContainers = ({ serverId }: Props) => {
refetch: refetchNodes,
} = api.swarm.getNodes.useQuery({ serverId });
- // 2. Fetch services (same endpoint the Overview tab uses)
const {
data: nodeApps,
isLoading: appsLoading,
@@ -46,7 +47,6 @@ export const ShowSwarmContainers = ({ serverId }: Props) => {
{ enabled: !nodesError && nodes !== undefined },
);
- // 3. Fetch task details for each service
const applicationList =
nodeApps && nodeApps.length > 0
? nodeApps.map((app: { Name: string }) => app.Name)
@@ -61,7 +61,6 @@ export const ShowSwarmContainers = ({ serverId }: Props) => {
{ enabled: applicationList.length > 0 },
);
- // 4. Fetch container stats for metrics
const { data: stats, isLoading: statsLoading } =
api.swarm.getContainerStats.useQuery(
{ serverId },
@@ -111,7 +110,6 @@ export const ShowSwarmContainers = ({ serverId }: Props) => {
}
}
- // Separate running containers from unscheduled services (no tasks / scaled to 0)
const runningContainers = containers.filter(
(c) =>
c.Node !== "N/A" &&
@@ -120,15 +118,12 @@ export const ShowSwarmContainers = ({ serverId }: Props) => {
const unscheduledServices = containers.filter((c) => c.Node === "N/A");
- // Detect down or unavailable nodes
const downNodes = (nodes ?? []).filter(
(n: SwarmNode) => n.Status !== "Ready" || n.Availability !== "Active",
);
- // Detect if this is a multi-node swarm (metrics only available on manager)
const isMultiNode = (nodes?.length ?? 0) > 1;
- // Build node status lookup
const nodeStatusMap = new Map();
if (nodes) {
for (const node of nodes) {
@@ -136,255 +131,6 @@ export const ShowSwarmContainers = ({ serverId }: Props) => {
}
}
- // Auto-expand all nodes on first load
- useEffect(() => {
- if (runningContainers.length > 0 && expandedNodes.size === 0) {
- const nodeNames = new Set();
- for (const c of runningContainers) {
- if (c.Node) {
- nodeNames.add(c.Node);
- }
- }
- setExpandedNodes(nodeNames);
- }
- }, [runningContainers.length]);
-
- // --- Render: loading state ---
- if (isLoading) {
- return (
-
- Loading containers...
-
-
- );
- }
-
- // --- Render: swarm not active / unreachable (tRPC error) ---
- if (nodesError) {
- return (
- refetchNodes()}
- />
- );
- }
-
- // --- Render: nodes returned undefined (docker command failed silently) ---
- if (!nodesError && nodes === undefined) {
- return (
- refetchNodes()}
- />
- );
- }
-
- // --- Render: swarm active but getNodeApps failed (real error, not just empty) ---
- const isRealAppsError =
- appsError && !appsErrorDetail?.message?.includes("data is undefined");
- if (isRealAppsError) {
- return (
-
-
-
- Failed to Load Services
-
- Swarm is reachable but service listing failed.{" "}
- {appsErrorDetail?.message && (
-
- {appsErrorDetail.message}
-
- )}
-
-
-
-
This could be caused by:
-
-
Permission issues running Docker commands on the server
-
Docker daemon not responding
-
- Network connectivity issues to a remote server — check{" "}
-
- Cluster Settings
-
-
-
-
-
-
- );
- }
-
- // --- Render: swarm active, but no services deployed ---
- if (!nodeApps || nodeApps.length === 0) {
- return (
-
-
-
- No Swarm Services Found
-
- Docker Swarm is active with{" "}
- {nodes?.length ?? 0} node(s), but there are no
- application services running in the swarm.
-
-
-
- To see containers in this view, make sure your applications are:
-
-
-
- Deployed as Swarm services — Applications
- in Dokploy deploy to Swarm by default. Docker Compose projects
- need to use{" "}
-
- Stack
- {" "}
- type (not{" "}
-
- Docker Compose
-
- ) to run as Swarm services.
-
-
- Using a registry (for multi-node setups) —
- Worker nodes need to pull images from a shared registry. Configure
- one in{" "}
-
- Cluster Settings
-
- .
-
-
- Successfully built and deployed — Check
- your project's deployment logs for errors.
-