Working with Docker python Sdk for swarm services
In this example, we are going to create
Get instance of a client. (Please make sure you have installed python docker library using pip docker)
Get client instance
client = docker.from_env()
Create an swarm service using nginx image
client.services.create('nginx:latest', None, name="nginx_latest")
To scale up (if you only have 1 service running)
client.services.list()[0].scale(3)
For more info, please go here.
https://docker-py.readthedocs.io/en/stable/services.html
Comments