Swarm

class aiodocker.swarm.DockerSwarm(docker)[source]
async init(*, advertise_addr: str | None = None, data_path_port: int | None = None, default_addr_pool: list | None = None, listen_addr: str = '0.0.0.0:2377', force_new_cluster: bool = False, subnet_size: int = 24, swarm_spec: Mapping | None = None) str[source]

Initialize a new swarm.

Parameters:
  • ListenAddr – listen address used for inter-manager communication

  • AdvertiseAddr – address advertised to other nodes.

  • DataPathPort – address or interface to use for data path traffic

  • DefaultAddrPool – default subnet pools for global scope networks

  • SubnetSize – subnet size of the networks created from the default subnet pool

  • ForceNewCluster – Force creation of a new swarm.

  • SwarmSpec – User modifiable swarm configuration.

Returns:

id of the swarm node

async inspect() Mapping[source]

Inspect a swarm.

Returns:

Info about the swarm

async join(*, remote_addrs: Iterable[str], listen_addr: str = '0.0.0.0:2377', join_token: str, advertise_addr: str | None = None, data_path_addr: str | None = None) bool[source]

Join a swarm.

Parameters:
  • listen_addr – Used for inter-manager communication

  • advertise_addr – Externally reachable address advertised to other nodes.

  • data_path_addr – Address or interface to use for data path traffic.

  • remote_addrs – Addresses of manager nodes already participating in the swarm.

  • join_token – Secret token for joining this swarm.

async leave(*, force: bool = False) bool[source]

Leave a swarm.

Parameters:

force – force to leave the swarm even if the node is a master