From af03208da76c736d709c5277a0c606f06c1d95ed Mon Sep 17 00:00:00 2001 From: David Boreham Date: Wed, 25 Jan 2023 23:22:05 -0700 Subject: [PATCH] Exec command inside container Former-commit-id: ade20fb2f50e1f8c034c946c2f379d7259bca970 --- app/deploy_system.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/deploy_system.py b/app/deploy_system.py index da2ed06..904c7f6 100644 --- a/app/deploy_system.py +++ b/app/deploy_system.py @@ -98,6 +98,15 @@ def command(ctx, include, exclude, cluster, command, extra_args): if verbose: print("Running compose down") docker.compose.down() + elif command == "exec": + if extra_args_list is None or len(extra_args_list) < 2: + print("Usage: exec ") + sys.exit(1) + service_name = extra_args_list[0] + command_to_exec = extra_args_list[1:] + if verbose: + print(f"Running compose exec {service_name} {command_to_exec}") + docker.compose.execute(service_name, command_to_exec) elif command == "port": if extra_args_list is None or len(extra_args_list) < 2: print("Usage: port ") @@ -105,7 +114,7 @@ def command(ctx, include, exclude, cluster, command, extra_args): service_name = extra_args_list[0] exposed_port = extra_args_list[1] if verbose: - print("Running compose port") + print(f"Running compose port {service_name} {exposed_port}") mapped_port_data = docker.compose.port(service_name, exposed_port) print(f"{mapped_port_data[0]}:{mapped_port_data[1]}") elif command == "ps":