Skip to content

Commit e05ea16

Browse files
authored
Add an option to remove exited container#8
Add an option to remove exited container
2 parents 6dc32ad + 271f26e commit e05ea16

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
@@ -28,6 +28,7 @@ def create_localstack_container(
2828
image_name: str = LOCALSTACK_IMAGE_NAME,
2929
image_tag: str = LATEST_TAG,
3030
gateway_listen: str = "0.0.0.0:4566",
31+
auto_remove: bool = False,
3132
environment_variables: dict | None = None,
3233
bind_ports: dict | None = None,
3334
**kwargs,
@@ -51,6 +52,7 @@ def create_localstack_container(
5152
image_name,
5253
ports=bind_ports,
5354
environment=environment_variables,
55+
auto_remove=auto_remove,
5456
detach=True,
5557
)
5658

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)