0

As we know in docker swarm we can have more than one manger. Let's suppose that we have 2 nodes and 2 managers (so each node is both manager and worker).

Now, let client (using CLI tool) execute following two seperated scenarios:
1. docker create service some_service
2. docker update --force some_service
where client is launched on one of swarm nodes.
Where will above requests be sent? Only to leader or to each worker node? How docker deal with simultaneous requests?

Developer
  • 23
  • 3

1 Answers1

0

I assume you're talking about the docker cli talking to the manager api.

The docker cli on a node will default to connecting to localhost. Assuming you're on a manager, you can see which node your cli is talking to with docker node ls.

The * next to a node name indicates that's the one you're talking to.

From there if that node isn't the Leader, it will relay the commands to the Leader node and wait on a response to return to your cli. This all means:

  1. Just ensure you're running the docker cli on a manager node or your cli is configured to talk to one.
  2. It doesn't matter which manager, as they will all relay your command to the current Leader.
Bret Fisher
  • 8,164
  • 2
  • 31
  • 36
  • So my CLI (and also managers) pass my command to leader? And then (using RAFT) all managers make a decision about my command? – Developer Oct 08 '18 at 06:42
  • AFAIK managers don't make a consensus vote about each operation, only about leader election. Managers that aren't leaders are effectively a read-only copy. – Bret Fisher Oct 08 '18 at 18:51
  • Your CLI talks to one machine, which by default is the local machine. If that machine is a manager, then swarm commands will work. That machine passes commands to leader if they are not it. – Bret Fisher Oct 08 '18 at 18:52