docker swarm
SwarmCLI
ca
ca(ca_certificate=None, ca_key=None, certificate_expiry=None, detach=False, external_ca=None, rotate=False)
Get and rotate the root CA
PARAMETER | DESCRIPTION |
---|---|
ca_certificate |
Path to the PEM-formatted root CA certificate to use for the new cluster
TYPE:
|
ca_key |
Path to the PEM-formatted root CA key to use for the new cluster
TYPE:
|
certificate_expiry |
Validity period for node certificates
TYPE:
|
detach |
Exit immediately instead of waiting for the root rotation
to converge. The function will return
TYPE:
|
external_ca |
Specifications of one or more certificate signing endpoints
TYPE:
|
rotate |
Rotate the swarm CA - if no certificate or key are provided, new ones will be generated.
TYPE:
|
init
init(advertise_address=None, autolock=False, availability='active', data_path_address=None, data_path_port=None, listen_address=None)
Initialize a Swarm.
If you need the token to join the new swarm from another node,
use the docker.swarm.join_token
function.
A example of how to initialize the whole swarm without leaving the manager if the manager has ssh access to the workers:
from python_on_whales import docker, DockerClient
worker_docker = DockerClient(host="ssh://worker_linux_user@worker_hostname")
# Here the docker variable is connected to the local daemon
# worker_docker is a connected to the Docker daemon of the
# worker through ssh, useful to control it without login to the machine
# manually.
docker.swarm.init()
my_token = docker.swarm.join_token("worker") # you can set manager too
worker_docker.swarm.join("manager_hostname:2377", token=my_token)
PARAMETER | DESCRIPTION |
---|---|
advertise_address |
Advertised address (format:
TYPE:
|
autolock |
Enable manager autolocking (requiring an unlock key to start a stopped manager)
TYPE:
|
availability |
Availability of the node ("active"|"pause"|"drain")
TYPE:
|
data_path_address |
Address or interface to use for data path
traffic (format is
TYPE:
|
listen_address |
address upon which the node listens for inbound
swarm manager traffic (format:
TYPE:
|
join
join(manager_address, advertise_address=None, availability='active', data_path_address=None, listen_address=None, token=None)
Joins a swarm
PARAMETER | DESCRIPTION |
---|---|
manager_address |
The address of the swarm manager in the format
TYPE:
|
advertise_address |
Advertised address (format:
TYPE:
|
availability |
Availability of the node
(
TYPE:
|
data_path_address |
Address or interface to use for data
path traffic (format:
TYPE:
|
listen_address |
Listen address (format:
TYPE:
|
token |
Token for entry into the swarm, will determine if the node enters the swarm as a manager or a worker.
TYPE:
|
join_token
join_token(node_type, rotate=False)
Obtains a token to join the swarm
This token can then be used
with docker.swarm.join("manager:2377", token=my_token)
.
PARAMETER | DESCRIPTION |
---|---|
node_type |
TYPE:
|
rotate |
Rotate join token
TYPE:
|
leave
leave(force=False)
Leave the swarm
PARAMETER | DESCRIPTION |
---|---|
force |
Force this node to leave the swarm, ignoring warnings
TYPE:
|
unlock
unlock(key)
Unlock a swarm after the --autolock
parameter was used and
the daemon restarted.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to unlock the swarm. The key can be obtained on any manager
with
TYPE:
|
unlock_key
unlock_key(rotate=False)
Gives you the key needed to unlock the swarm after a manager daemon reboot.
PARAMETER | DESCRIPTION |
---|---|
rotate |
Rotate the unlock key.
TYPE:
|
update
update(autolock=None, cert_expiry=None, dispatcher_heartbeat=None, external_ca=None, max_snapshots=None, snapshot_interval=None, task_history_limit=None)
Update the swarm configuration
PARAMETER | DESCRIPTION |
---|---|
autolock |
Change manager autolocking setting
TYPE:
|
cert_expiry |
Validity period for node certificates, default
is
TYPE:
|
dispatcher_heartbeat |
Dispatcher heartbeat period.
TYPE:
|
external_ca |
Specifications of one or more certificate signing endpoints
TYPE:
|
max_snapshots |
Number of additional Raft snapshots to retain
TYPE:
|
snapshot_interval |
Number of log entries between Raft snapshots (default 10000)
TYPE:
|
task_history_limit |
Task history retention limit (default 5)
TYPE:
|