Skip to content

Commit 4324b79

Browse files
committed
add an option to remove exited container
1 parent 96b1d50 commit 4324b79

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

localstack_utils/container.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def create_localstack_container(
3131
environment_variables: dict = None,
3232
bind_ports: dict = None,
3333
pro: bool = False,
34+
auto_remove: bool = False,
3435
):
3536
environment_variables = environment_variables or {}
3637
environment_variables["GATEWAY_LISTEN"] = gateway_listen
@@ -56,6 +57,7 @@ def create_localstack_container(
5657
image_name_or_default,
5758
ports=bind_ports,
5859
environment=environment_variables,
60+
auto_remove=auto_remove,
5961
detach=True,
6062
)
6163

localstack_utils/localstack.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def startup(self, docker_configuration):
4848
docker_configuration.environment_variables,
4949
docker_configuration.port_mappings,
5050
docker_configuration.pro,
51+
docker_configuration.auto_remove_container,
5152
)
5253

5354
self.setup_logger()
@@ -77,6 +78,7 @@ def startup_localstack(
7778
env_variables=None,
7879
gateway_listen="",
7980
ignore_docker_errors=False,
81+
auto_remove_container=False,
8082
):
8183
global localstack_instance
8284
localstack_instance = Localstack.INSTANCE()
@@ -101,6 +103,9 @@ def startup_localstack(
101103
if gateway_listen:
102104
config.gateway_listen = gateway_listen
103105

106+
if auto_remove_container:
107+
config.auto_remove_container = auto_remove_container
108+
104109
localstack_instance.startup(config)
105110

106111

localstack_utils/localstack_docker_configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ class LocalstackDockerConfiguration:
1414
use_dingle_docker_container = False
1515
ignore_docker_runerrors = False
1616
pro = False
17+
auto_remove_container = False

0 commit comments

Comments
 (0)