Docker Community Forums

Share and learn in the Docker community.

How to share service to swarm

I join in docker worker hub (nodeY) to swarm. My service (it expose secret) has created in docker swarm manager (nodeX). When I try access in nodeY to service exposed by nodeY I always receive:
Error response from daemon: 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.

please share the exact command or docker-compose.yml that show what you actualy do.

–no firewall in both machines and both machines directly connected one to another
X: docker init
X: docker service create …
Y: docker swarm join --token YYYYY (YYY - worker token)
X: docker node promote x-name
Y: docker node info
Error: manager stopped: can’t initialize raft node: rpc error: code = Unknown desc = could not connect to prospective new cluster member using its advertised address: rpc error: code = DeadlineExceeded desc = context deadline exceeded
Y: docker service list
Error response from daemon: This node is not a swarm manager. Use “docker swarm init” or “docker swarm join” to connect this node to swarm and try again.

I assume this a typo? Please share the ouput of docker node ls.
From what I see, Y joined as worker and is not promoted to be a manager node. Thus, all swarm related commands are not executable on that node. This is the expected behavior, as swarm related commands are only executable on manager nodes.

Hint: running two manager nodes is more brittle than running a single manager. With two manager nodes, the outage of either one of them will render your cluster headless. Always use an odd number of manager nodes!

Thank you for answer, but no interesting at all to working with one manager node. Even simplest as possible task need multimanager node. For example I want to create protected password and share it for all my swarm. Its a simple as possible task. But for a couple of days I can do not solve this extremely simplest task. I see only a lot of various error messages.

Is this your takeaway of make it an odd number?
From your response, I take away that you haven’t been able to read the docs up to a point that allowed you to understand how swarm actualy works…

If you are actualy interessted in understanding how things work, I can recommend this free self-paced training:

Good luck!