Can I use manager node as docker server?

Hello,
Do I have to allocate a server for the manager node? Can I have containers on the manager node?

Thank you.

You can run Docker services on Docker Swarm manager and worker nodes.

Note that 3 manager nodes are required for HA.

1 Like

Hi,
Thanks a lot for your reply.
Iā€™m thankful if you make some things clear to me. I have three Docker servers and Nginx and Node containers are running on each of them. You said that for HA three manager nodes are needed. The address of my servers is as follows:

Server-1: 192.168.1.1
Server-2: 192.168.1.2
Server-2: 192.168.1.3

On each of the servers I have to execute the following command:

# docker swarm init --advertise-addr Server-IP

What are the worker node commands? I know that the command is as follows:

# docker swarm join-token <TOKEN> <MANAGER_NODE_IP>:2377

Do I need to enter the Server-2 and Server-3 IP addresses for Server-1? For example, On Server-1:

# docker swarm join-token <Server-2_TOKEN> 192.168.1.2:2377
# docker swarm join-token <Server-3_TOKEN> 192.168.1.3:2377

Right?

You run docker swarm init on a single node, then you join all others as manager or worker (doc).

1 Like

Thanks again.
So do I need four servers? One to execute the docker Swarm init command and the other three as the worker nodes, or can I run the docker Swarm init command on one of the three servers?

You need one init, which will be first manager, then you join others to the first one. As manager or worker.

For HA you need 3 managers.

1 Like

Thanks again.
According to the following explanation:

Manager node : Maintains cluster management tasks 

Worker node  : Receives and executes tasks from the manager node

1- Are the worker nodes the servers that the containers run on?

2- Can I use manager node (init) as worker node?

Yes, I thought that was the original question.

You can add a constraint in deploy section if you wish to pin containers to dedicated nodes. But in general Swarm will run containers on any member of the Swarm, does not matter if manager or worker.

1 Like

Thanks again.
Assuming my servers are as follows:

Server-1: 192.168.1.1
Server-2: 192.168.1.2
Server-2: 192.168.1.3

I need three manager nodes for HA. So I need to run the following command on each server:

# docker swarm init --advertise-addr Server-IP

Now, the next command is as follows. Do I have to run this command on all three servers?

# docker swarm join --token <TOKEN> <MANAGER_NODE_IP>:2377

Hello,
Can anyone tell me what commands to run on each server? I saw various things on the Internet.

Thank you.

Did you read the friendly manual?

Hi,
Thank you so much for your reply.
I did, but you told me that I need 3 managers and I only have 3 servers.

The swarm init server is automatically a manager, then join 2 more servers as manager.