def attach(): """ attach to the running container """ env.docker("attach %s" % env.container_name)
def run(ep='', **kwargs): """ execute the container ep - specify an alternate entrypoint, e.g., "ep=bash" **kwargs - additional kwargs will be converted to environment variables passed to container """ vols = "-v /var/log/syslog:/var/log/syslog" evars = len(kwargs) and ' '.join(["-e %s=%s" % (x[0],x[1]) for x in kwargs.items()]) or '' env.docker("run -d -t -i --name adsabs-forwarder %s %s adsabs/forwarder %s" \ % (evars, vols, ep))
def run(ep='', detach=False, **kwargs): """ execute the container ep - specify an alternate entrypoint, e.g., "ep=bash" **kwargs - additional kwargs will be converted to environment variables passed to container """ ports = "-p 8080:8080" evars = len(kwargs) and ' '.join(["-e %s=%s" % (x[0],x[1]) for x in kwargs.items()]) or '' detach = detach and "-d" or "" env.docker("run %s -t -i --name %s %s %s %s %s" \ % (detach, env.container_name, evars, ports, env.image_name, ep))
def data_backup(output_dir, output_file="adsloggingdata.tar"): from tempfile import mkdtemp tmpdir = mkdtemp() # TODO: use elasticsearch snapshots to do this # SEE: http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html # 1. create snapshot registry # 2. create snapshot # 3. tar the snapshot as before # 4. delete snapshot # 5. delete registry? env.docker("run --rm --volumes-from adsabs-adsloggingdata -v %s:/backup busybox tar -cf /backup/%s /data" \ % (tmpdir, output_file)) local("mv %s %s" % (os.path.join(tmpdir, output_file), os.path.join(output_dir, output_file))) # force remove the temp directory in case something went wrong with previous comand local("rm -rf %s" % tmpdir)
def run(ep='', **kwargs): """ execute the containers ep - specify an alternate entrypoint, e.g., "ep=bash" **kwargs - additional kwargs will be converted to environment variables passed to container """ for conf in config: if conf['name'] not in env.containers: continue ports = conf.has_key('ports') and ' '.join("-p %s" % p for p in conf['ports']) or '' vfrom = conf.has_key('vfrom') and '--volumes-from %s' % conf['vfrom'] or '' links = conf.has_key('links') and ' '.join("--link %s" % l for l in conf['links']) or '' evars = len(kwargs) and ' '.join(["-e %s=%s" % (x[0],x[1]) for x in kwargs.items()]) or '' entrypoint = conf.has_key('entrypoint') and conf['entrypoint'] or ep env.docker("run -d -t -i --name adsabs-%s %s %s %s %s adsabs/%s %s" \ % (conf['name'], evars, ports, vfrom, links, conf['name'], entrypoint))
def data(yes=False): """ remove and recreate the shared data container. WARNING! this will delete existing data & logs! """ # start the data container with settings(hide('running', 'stdout', 'stderr')): containers = env.docker('ps -a', capture=True) if not yes: if not confirm("This will erase all existing data. Are you sure?", default=False): print cyan("OK, nevermind") return if 'adsabs-adsloggingdata' in containers: env.docker("stop adsabs-adsloggingdata") env.docker("rm adsabs-adsloggingdata") env.docker('run --name="adsabs-adsloggingdata" -v /data -v /var/log/supervisor ventz/dataos true')
def rmi(): """ remove the image """ env.docker("rmi adsabs/forwarder")
def build(): """ build the container """ env.docker("build -t adsabs/forwarder .")
def rm(): """ remove the container """ env.docker("rm %s" % env.container_name)
def stop(): """ stop the container """ env.docker("stop %s" % env.container_name)
def build(): """ build the container """ env.docker("build -t %s ." % env.image_name)
def build(): """ build the containers """ for name in env.containers: env.docker("build -t adsabs/%s dockerfiles/%s" % (name, name))
def rm(): """ remove the containers """ for c in env.containers: env.docker("rm adsabs-%s" % c)
def stop(): """ stop the containers """ for c in env.containers: env.docker("stop adsabs-%s" % c)
def stop(): """ stop the container """ env.docker("stop adsabs-forwarder")
def rmi(): """ remove the image """ env.docker("rmi %s" % env.image_name)
def rm(): """ remove the container """ env.docker("rm adsabs-forwarder")
def rmi(): """ remove the images """ for name in env.containers: env.docker("rmi adsabs/%s" % name)