dsnssc
dsnssc

Reputation: 97

Docker Swarm managers acting nodes?

I've created setup with 3 swarm managers and 3 nodes.

You e can see below that in the case with 3 masters and 3 workers actually I have 3 managers and 6 nodes. Is it idea that managers are also capable to run containers, not just workers? Am I missing something in the setup or this is intended to work as it is now?

when I execute docker info command, I am getting this output:

ubuntu@manager3:~$ docker info
Containers: 4
 Running: 3
 Paused: 0
 Stopped: 1
Images: 3
Server Version: 1.12.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 23
 Dirperm1 Supported: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: overlay bridge host null
Swarm: active
 NodeID: 9uv3xhwzibx52xghpsa0sp3f7
 Is Manager: true
 ClusterID: 04r095rvj6b4i7ygbnr2quo9e
 **Managers: 3
 Nodes: 6**
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot interval: 10000
  Heartbeat tick: 1
  Election tick: 3
 Dispatcher:
  Heartbeat period: 5 seconds
 CA configuration:
  Expiry duration: 3 months
 Node Address: 172.100.0.23
Runtimes: runc
Default Runtime: runc
Security Options: apparmor
Kernel Version: 3.13.0-92-generic
Operating System: Ubuntu 14.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 992.5 MiB
Name: manager3
ID: MUXB:GUNV:HIDO:APRJ:S2JU:763E:QSOL:2554:EZJL:L4OI:6TS5:RD7O
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
 127.0.0.0/8

when I create some services to run on swarm cluster:

docker service create --replicas=3 --name redis redis:latest

Some of them will run on managers, some on workers. That's confusing me.

if I create more services

docker service create --replicas=6 --name redis redis:latest

they will run on all machines in cluster. increasing even more will start failing due to port collision.

Upvotes: 0

Views: 2197

Answers (2)

dsnssc
dsnssc

Reputation: 97

Thanks to @Mark O'Connor answer is:

By default manager nodes also act as a worker nodes.

Manager can be drained and stay "only" manager, so you will execute this command to manager stops being worker:

docker node update --availability drain *manager_name*

Upvotes: 3

Bernard
Bernard

Reputation: 17311

A node (host) running as a swarm manager isn't different than one running as a worker as far as running services is concerned. It's perfectly fine to have a 3 node swarm with a swarm manager on each one (and no worker).

As for port collision, you need to specify the public port (on the host) when you create the service. Eg:

docker create service --name redis --publish 8080:80 --replicas 5 redis:latest

Docker will then load balance any incoming request to port 8080 on any of the nodes to one of the redis containers on the cluster (not necessarily on the same node as the incoming request)

Upvotes: 3

Related Questions