This error occurs when you run a swarm management command on a Docker node that hasn't been initialized as a swarm manager. The fix is to either initialize a new swarm with `docker swarm init` or join an existing swarm as a manager node.
Docker Swarm is Docker's native clustering and orchestration solution. In a swarm, nodes can have one of two roles: **manager** or **worker**. Manager nodes handle cluster management tasks like maintaining cluster state, scheduling services, and serving the swarm mode HTTP API. Worker nodes execute containers but cannot perform management operations. When you run swarm management commands like `docker node ls`, `docker service ls`, `docker stack deploy`, or `docker secret ls`, these commands must be executed on a manager node. If the Docker daemon you're connected to is either not part of any swarm or is only a worker node, you'll see this "This node is not a swarm manager" error. This commonly happens in these scenarios: - Running swarm commands on a fresh Docker installation that was never initialized as a swarm - Attempting to use overlay networks without swarm mode (overlay networks require swarm) - Running management commands while connected to a worker node instead of a manager - After a Mac/Windows system wakes from sleep (Docker Desktop may lose swarm state) - Trying to use Docker secrets outside of swarm mode (secrets require swarm)
First, check if your Docker node is part of a swarm and what its role is:
docker info --format '{{.Swarm.LocalNodeState}}'Possible outputs:
- inactive - Not part of any swarm
- active - Part of a swarm (check role next)
- pending - In process of joining a swarm
- locked - Swarm is locked, needs to be unlocked
If active, check if you're a manager:
docker info --format '{{.Swarm.ControlAvailable}}'Returns true for managers, false for workers.
If docker info shows Swarm: inactive, initialize a new swarm:
docker swarm initThis creates a new single-node swarm with your current node as the manager.
If you have multiple network interfaces, specify which IP to advertise:
docker swarm init --advertise-addr <YOUR_IP>After initialization, your node becomes both a manager and a worker by default.
If a swarm already exists and you need to join it as a manager, get the join token from an existing manager:
On an existing manager node:
docker swarm join-token managerThis outputs a command like:
docker swarm join --token SWMTKN-1-xxx <MANAGER_IP>:2377On the node you want to add:
Run the command output from above. Your node will join as a manager.
If you're on a manager node and need to promote a worker:
# List all nodes
docker node ls
# Promote a worker to manager
docker node promote <NODE_ID_OR_HOSTNAME>You can also demote a manager to worker if needed:
docker node demote <NODE_ID_OR_HOSTNAME>Note: Always maintain an odd number of managers for proper quorum.
If swarm stopped working after system sleep or restart on Docker Desktop:
Option 1: Restart Docker Desktop
- Right-click the Docker icon in the system tray
- Select "Restart"
Option 2: Leave and reinitialize swarm
docker swarm leave --force
docker swarm initOption 3: Reset Docker Desktop to factory defaults
- Open Docker Desktop Settings
- Go to "Troubleshoot" or "Reset"
- Click "Reset to factory defaults" (this removes all containers, images, and volumes)
Confirm swarm is working:
# Check swarm status
docker info | grep -A 5 "Swarm"
# List nodes (should work without error)
docker node ls
# Test service creation
docker service create --name test-nginx --replicas 1 nginx
docker service ls
docker service rm test-nginxIf all commands succeed, swarm mode is working correctly.
### Using Overlay Networks Without Swarm
If you only need overlay networks for container communication and don't need full swarm orchestration, you still need to initialize swarm mode, but you can do so as a single-node swarm:
docker swarm init
# Now you can create overlay networks
docker network create --driver overlay --attachable my-overlayThe --attachable flag allows standalone containers (not just swarm services) to connect to the overlay network.
### Using Secrets Without Swarm
Docker secrets require swarm mode. If you need secrets on a single node without full swarm orchestration, alternatives include:
1. Initialize a single-node swarm (simplest)
2. Use Docker Compose with secrets from files
3. Use environment variables or mounted config files (less secure)
### Swarm Manager Quorum
Swarm uses the Raft consensus algorithm. For a swarm with N managers:
- Tolerates (N-1)/2 manager failures
- 3 managers: tolerates 1 failure
- 5 managers: tolerates 2 failures
- 7 managers: tolerates 3 failures
If quorum is lost, you cannot manage the swarm until it's restored. You may see "This node is not a swarm manager" even on a manager node if the cluster has lost quorum.
### Recovering from Lost Quorum
If your swarm lost quorum:
# Force a new cluster with this node as the only manager
docker swarm init --force-new-clusterThis recovers the swarm state from the current node. Other managers will need to rejoin.
### Ports Required for Swarm
Ensure these ports are open between swarm nodes:
- 2377/tcp: Cluster management communications
- 7946/tcp+udp: Container network discovery
- 4789/udp: Overlay network traffic (VXLAN)
dockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
Error response from daemon: manifest for nginx:nonexistent not found: manifest unknown: manifest unknown
How to fix 'manifest for image:tag not found' in Docker
Error response from daemon: invalid reference format: repository name must be lowercase
How to fix 'repository name must be lowercase' in Docker
Error response from daemon: No such image
How to fix 'No such image' in Docker
Error response from daemon: Container is not running
How to fix 'Container is not running' when using docker exec