Docker swarm run tasks only in workers

若如初见. 提交于 2019-12-01 04:14:20

While you can use constraints (with --constraint node.role=worker) to eliminate a subset of nodes based on their role (manager or worker), I would go as far as disabling the Manager(s) from acting like Worker(s) with:

# Disables the Manager as a Worker node

docker node update --availability drain manager1

The idea is that the Manager should be kept secure from resource overload (CPU, RAM, fds), that could happen if the resources used by deployed services is higher than the resources available on a Manager. It can trigger a failure cascade scenario and the cluster could become highly unstable (or not responding to any more requests).

The Manager, at its core, maintains critical components (like certificate issuance and rotation, distributed datastore, networking), it would be bad to make your entire cluster unstable because the Managers are running out of resources.

Related Issues:

Source: I was a maintainer of Docker Swarm and wrote the Administration Guide for Swarm mode.

Yes, you can constrain a service based on node role. Change your command to:

docker service create --network dognet --constraint node.role==worker --name dog-db redis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!