Added -a option for platydock to attach to the instance after booting it up

This commit is contained in:
Fabio Manganiello 2020-02-03 16:57:40 +01:00
parent 96bdefdaf3
commit 8d203723da

View file

@ -221,6 +221,12 @@ def start(args):
-p 18008:8008 -p 18009:8009 -p 18008:8008 -p 18009:8009
''')) '''))
parser.add_argument('-a', '--attach', action='store_true', default=False,
help=textwrap.dedent('''
If set, then attach to the container after starting it up (default: false).
'''))
opts, args = parser.parse_known_args(args) opts, args = parser.parse_known_args(args)
ports = {} ports = {}
dockerfile = os.path.join(workdir, opts.image, 'Dockerfile') dockerfile = os.path.join(workdir, opts.image, 'Dockerfile')
@ -252,6 +258,9 @@ def start(args):
print('Starting Platypush container {}'.format(opts.image)) print('Starting Platypush container {}'.format(opts.image))
subprocess.call(docker_cmd) subprocess.call(docker_cmd)
if opts.attach:
subprocess.call(['docker', 'attach', opts.image])
def stop(args): def stop(args):
parser = argparse.ArgumentParser(prog='platydock stop', parser = argparse.ArgumentParser(prog='platydock stop',