check_swarm status checking is implemented by requesting http:/swarm URL, whereas this seems to works only on manager nodes:
$> curl --unix-socket /var/run/docker.sock http:/swarm
{"message":"This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager."}
Parsing http:/info result seems a more portable option.
I checked it with docker versions 19.03.14 and 20.10.7.
check_swarm status checking is implemented by requesting http:/swarm URL, whereas this seems to works only on manager nodes: $> curl --unix-socket /var/run/docker.sock http:/swarm {"message":"This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager."}
Parsing http:/info result seems a more portable option.
I checked it with docker versions 19.03.14 and 20.10.7.