Skip to content

Instantly share code, notes, and snippets.

@josephbolus
Forked from flux7-user/multi-tenant-docker.py
Created February 13, 2014 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephbolus/8983876 to your computer and use it in GitHub Desktop.
Save josephbolus/8983876 to your computer and use it in GitHub Desktop.
# Yes. We love Python!
def start_provider(provider_id, gateway_port, admin_port ):
docker_client = docker.Client(base_url='unix://var/run/docker.sock',
version='1.6',
timeout=100)
# start a docker container for consuming gateway data at gateway_port
start_command = 'python software/remote_server.py ' + provider_id
remote_server = docker_client.create_container('flux7/labs', # docker image
command=start_command, # start command contains the keyspace parameter, keyspace is the provider_id
name='remote_server_' + provider_id, # name the container, name is provider_id
ports=[(6000, 'tcp'),]) # open port for binding, remote_server.py listens at 6000
docker_client.start(remote_server,
port_bindings={6000: ('0.0.0.0', gateway_port)},
links={'db': 'cassandra'})
# start a docker container for serving admin panel at admin_port
start_command = 'python software/flask_app.py ' + provider_id
remote_server = docker_client.create_container('flux7/labs', # docker image
command=start_command, # start command contains the keyspace parameter, keyspace is the provider_id
name='admin_panel_' + provider_id, # name the container, name is provider_id
ports=[(80, 'tcp'),]) # open port for binding, remote_server.py listens at 6000
docker_client.start(remote_server,
port_bindings={80: ('0.0.0.0',admin_port)},
links={'db': 'cassandra'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment