demote

docker.node.demote(x)

Demote one or more nodes from manager in the swarm

Arguments

  • x Union[python_on_whales.Node, str, List[Union[python_on_whales.Node, str]]]: One or a list of nodes.

inspect

docker.node.inspect(x)

Returns a python_on_whales.Node object from a string (id or hostname of the node)

Arguments

  • x Union[str, List[str]]: One id or hostname or a list of ids or hostnames

Returns

One or a list of python_on_whales.Node


list

docker.node.list()

Returns the list of nodes in this swarm.

Returns

A List[python_on_whales.Node]


promote

docker.node.promote(x)

Promote one or more nodes to manager in the swarm

Arguments

  • x Union[python_on_whales.Node, str, List[Union[python_on_whales.Node, str]]]: One or a list of nodes.

ps

docker.node.ps(x=None)

Returns the list of swarm tasks running on one or more nodes.

from python_on_whales import docker

tasks = docker.node.ps("my-node-name")
print(tasks[0].desired_state)
# running

Arguments

  • x Optional[Union[python_on_whales.Node, str, List[Union[python_on_whales.Node, str]]]]: One or more nodes (can be id, name or python_on_whales.Node object.). If the argument is not provided, it defaults to the current node. An empty list means an empty list will also be returned.

Returns

List[python_on_whales.Task]


remove

docker.node.remove(x, force=False)

Remove one or more nodes from the swarm

Arguments

  • x Union[python_on_whales.Node, str, List[Union[python_on_whales.Node, str]]]: One node or a list of nodes. You can use the id or the hostname of a node. You can also use a python_on_whales.Node.
  • force bool: Force remove a node from the swarm

update

docker.node.update(node, availability=None, labels_add={}, rm_labels=[], role=None)

Updates a Swarm node.

Arguments

  • node Union[python_on_whales.Node, str]: The node to update, you can use a string or a python_on_whales.Node object.
  • availability Optional[str]: Availability of the node ("active"|"pause"|"drain")
  • labels_add Dict[str, str]: Remove a node label if exists
  • rm_labels List[str]: Labels to remove from the node.
  • role Optional[str]: Role of the node ("worker"|"manager")