Skip to content

Latest commit

 

History

History
49 lines (28 loc) · 1.38 KB

README.rst

File metadata and controls

49 lines (28 loc) · 1.38 KB

Swarm

A swarm cluster manager based on the Python docker API

https://travis-ci.org/FNNDSC/swarm.svg?branch=master

The docker image can be run from a swarm manager to schedule a service:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock fnndsc/swarm swarm.py -s test -i alpine -c "echo test"

This will schedule the test service that runs command:

echo test

using the Alpine image

The same thing can be accomplished from Python code:

client = docker.from_env()
# 'remove' option automatically remove container when finished
byte_str = client.containers.run('fnndsc/swarm',  'swarm.py -s test -i alpine -c "echo test"',
                                 volumes={'/var/run/docker.sock': {'bind': '/var/run/docker.sock', 'mode': 'rw'}},
                                 remove=True)

To remove the test service:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock fnndsc/swarm swarm.py --remove test

or from Python:

byte_str = client.containers.run('fnndsc/swarm',  'swarm.py --remove test',
                                 volumes={'/var/run/docker.sock': {'bind': '/var/run/docker.sock', 'mode': 'rw'}},
                                 remove=True)