Skip to main content
The Swarm API provides endpoints to manage Docker Swarm clusters, inspect nodes, and retrieve service information.

Get Swarm Nodes

curl -X GET "https://your-dokploy-instance.com/api/swarm.getNodes?serverId=server_123" \
  -H "Authorization: Bearer YOUR_API_KEY"
Retrieve all nodes in the Docker Swarm cluster.

Query Parameters

serverId
string
The ID of the server to query. If not provided, queries the local server’s swarm.

Response

Returns an array of swarm node objects with detailed information including:
  • Node ID and hostname
  • Role (manager or worker)
  • Availability status
  • Node state and version
  • Resource information (CPU, memory)
  • Labels and platform details

Get Node Information

curl -X GET "https://your-dokploy-instance.com/api/swarm.getNodeInfo?nodeId=node_abc123&serverId=server_123" \
  -H "Authorization: Bearer YOUR_API_KEY"
Get detailed information about a specific swarm node.

Query Parameters

nodeId
string
required
The ID of the swarm node to retrieve information for.
serverId
string
The ID of the server where the swarm is running.

Response

Returns detailed node information including:
  • Full node specification
  • Current status and state
  • Manager status (if applicable)
  • Resource allocation
  • Platform and engine details
  • Labels and constraints

Get Node Applications

curl -X GET "https://your-dokploy-instance.com/api/swarm.getNodeApps?serverId=server_123" \
  -H "Authorization: Bearer YOUR_API_KEY"
Retrieve all applications deployed across swarm nodes.

Query Parameters

serverId
string
The ID of the server to query.

Response

Returns information about applications (services and stacks) running in the swarm cluster, including:
  • Service names and IDs
  • Replica counts and status
  • Node placement
  • Network configuration
  • Resource allocation

Understanding Docker Swarm in Dokploy

Docker Swarm mode enables you to create and manage a cluster of Docker nodes, providing:

High Availability

  • Multiple manager nodes for fault tolerance
  • Automatic leader election
  • Service health monitoring and automatic recovery

Load Balancing

  • Built-in ingress load balancing
  • Service discovery across the cluster
  • Automatic request routing

Scaling

  • Easy horizontal scaling of services
  • Rolling updates with zero downtime
  • Resource constraints and reservations

Security

  • Mutual TLS authentication between nodes
  • Encrypted control plane communication
  • Secret management for sensitive data

Node Roles

Manager Nodes
  • Orchestrate and manage the cluster
  • Maintain cluster state
  • Schedule services
  • Should have odd number (3, 5, 7) for quorum
Worker Nodes
  • Execute container workloads
  • Receive tasks from managers
  • Report status back to managers

Common Swarm Operations

Checking Cluster Health

  1. List all nodes to verify cluster membership
  2. Check node info for each manager to ensure reachability
  3. Review applications to confirm services are running

Service Distribution

Swarm automatically distributes service replicas across available nodes based on:
  • Node availability and state
  • Resource requirements
  • Placement constraints
  • Spread preferences

Best Practices

High Availability SetupFor production environments:
  • Use at least 3 manager nodes (distributed across availability zones)
  • Separate manager and worker roles for better resource utilization
  • Configure health checks for all services
  • Use resource limits to prevent resource exhaustion
Manager Node QuorumLosing quorum (more than half of managers down) prevents cluster management operations. Always maintain an odd number of managers and ensure they’re distributed for fault tolerance.

Error Handling

Common Error Responses

Node Not Found
{
  "error": "Node not found",
  "message": "The specified node ID does not exist in the swarm"
}
Swarm Not Initialized
{
  "error": "Swarm not available",
  "message": "This node is not part of a swarm. Initialize or join a swarm first."
}
Unauthorized Access
{
  "error": "Unauthorized",
  "message": "You don't have permission to access this server's swarm"
}

Build docs developers (and LLMs) love