mkswarm
CLI tool for bootstrapping and managing Docker Swarm clusters.
Install
pip install mkswarm
Usage
# Initialize a new Docker Swarm
mkswarm init -i ips.txt -m 192.168.1.1 -r 0.2 -o join.sh
# Run pending node joins via Docker SDK
mkswarm run 1
# Show swarm state
mkswarm status 1
# List all swarms
mkswarm list
# Regenerate join script from database
mkswarm reemit 1 -o new_join.sh
# Force-leave all nodes and destroy swarm
mkswarm destroy 1
IP File Format
Create a text file with one IPv4 address per line:
# Manager node
192.168.1.1
# Worker nodes
192.168.1.2
192.168.1.3
192.168.1.4
Token Encryption
Encrypt tokens at rest using Fernet:
# Generate a key
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
# Use with mkswarm
export MKSWARM_KEY="your-generated-key"
mkswarm init -i ips.txt -m 192.168.1.1 -r 0.2 -o join.sh -k "$MKSWARM_KEY"
Proxy Support
Use SOCKS4, SOCKS5, or HTTP proxy:
mkswarm init -i ips.txt -m 192.168.1.1 -r 0.2 -o join.sh -p socks5://proxy:1080
TLS Support
Configure mutual TLS for Docker TCP connections:
mkswarm init -i ips.txt -m 192.168.1.1 -r 0.2 -o join.sh \
--tls-cert client-cert.pem \
--tls-key client-key.pem \
--tls-ca ca.pem
CLI Options
Global Options
--db FILE- SQLite database path (default: swarm.db)--verbose- Enable debug logging--quiet- Suppress warnings--log-file FILE- Append logs to file--dry-run- Preview actions without contacting Docker or writing files
Subcommands
init- Bootstrap a new swarmrun- Join pending nodes via Docker SDKstatus- Show swarm statelist- List all swarmsreemit- Regenerate join script from DBdestroy- Force-leave all nodes
API
from mkswarm import SwarmDB, encrypt_token, decrypt_token, load_ips
# Database operations
db = SwarmDB("swarm.db")
swarm_id = db.create_swarm("192.168.1.1", "worker_token", "manager_token", 0.2, "192.168.1.1:2377", "join.sh")
swarm = db.get_swarm(swarm_id)
db.close()
# Token encryption
key = generate_key() # Generate new key
encrypted = encrypt_token(token, key)
decrypted = decrypt_token(encrypted, key)
# IP validation
ip = parse_ipv4("192.168.1.1")
ips = load_ips("ips.txt")
Development
git clone https://github.com/daedalus/mkswarm.git
cd mkswarm
pip install -e ".[test]"
# run tests
pytest
# format
ruff format src/ tests/
# lint
ruff check src/ tests/
# type check
mypy src/
License
MIT License - see LICENSE file for details.
Metadata
Release files for mkswarm 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mkswarm-0.1.1.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mkswarm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.6 kB
Release files / mkswarm-0.1.1.tar.gz
| Download URL | mkswarm-0.1.1.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
331ffd414ff3d2c1cae0cacfab432f735714f9a4f1da9a2419cb4c5a2f08d8c7
|
|
BLAKE2b-256 checksum How to use checksums |
2c54aab2dabe00f98339f022ea0d5096762b55669cad6f6f4fa44b7605d53939
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 11, 2026.
Transparency logRelease files / mkswarm-0.1.1-py3-none-any.whl
| Download URL | mkswarm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 21.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7ea86b46e1aa5d6442f67a5145870cd2442fb814e727626c383a1ac4a844483
|
|
BLAKE2b-256 checksum How to use checksums |
d1dd5a37c807346f75542348d7dbc2dbd7c0979c5521d5e54eda9735ce9336a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 11, 2026.
Transparency log