Skip to content

docker node

NodeCLI

demote

demote(x)

Demote one or more nodes from manager in the swarm

PARAMETER DESCRIPTION
x

One or a list of nodes.

TYPE: Union[ValidNode, List[ValidNode]]

inspect

inspect(x)

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

PARAMETER DESCRIPTION
x

One id or hostname or a list of ids or hostnames

TYPE: Union[str, List[str]]

Returns

One or a list of `python_on_whales.Node`

list

list()

Returns the list of nodes in this swarm.

Returns

A `List[python_on_whales.Node]`

promote

promote(x)

Promote one or more nodes to manager in the swarm

PARAMETER DESCRIPTION
x

One or a list of nodes.

TYPE: Union[ValidNode, List[ValidNode]]

ps

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
PARAMETER DESCRIPTION
x

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.

TYPE: Union[ValidNode, List[ValidNode], None] DEFAULT: None

Returns

`List[python_on_whales.Task]`

remove

remove(x, force=False)

Remove one or more nodes from the swarm

PARAMETER DESCRIPTION
x

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.

TYPE: Union[ValidNode, List[ValidNode]]

force

Force remove a node from the swarm

TYPE: bool DEFAULT: False

update

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

Updates a Swarm node.

PARAMETER DESCRIPTION
node

The node to update, you can use a string or a python_on_whales.Node object.

TYPE: ValidNode

availability

Availability of the node ("active"|"pause"|"drain")

TYPE: Optional[str] DEFAULT: None

labels_add

Remove a node label if exists

TYPE: Dict[str, str] DEFAULT: {}

rm_labels

Labels to remove from the node.

TYPE: List[str] DEFAULT: []

role

Role of the node ("worker"|"manager")

TYPE: Optional[str] DEFAULT: None