arnavn101 / swarm

A swarm cluster manager based on the Python docker API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

About

A swarm cluster manager based on the Python docker API

License:MIT License


Languages

Language:Python 95.0%Language:Dockerfile 5.0%