Skip to content

Commit 69334ec

Browse files
author
Mark Heiges
committed
configurable container name
1 parent 3329709 commit 69334ec

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
@@ -29,6 +29,7 @@ def create_localstack_container(
2929
pull_new_image: bool = False,
3030
image_name: str = LOCALSTACK_IMAGE_NAME,
3131
image_tag: str = LATEST_TAG,
32+
container_name: str = DEFAULT_CONTAINER_ID,
3233
gateway_listen: str = "0.0.0.0:4566",
3334
auto_remove: bool = False,
3435
environment_variables: dict | None = None,
@@ -52,6 +53,7 @@ def create_localstack_container(
5253

5354
return DOCKER_CLIENT.containers.run(
5455
image_name,
56+
name=container_name,
5557
ports=bind_ports,
5658
environment=environment_variables,
5759
auto_remove=auto_remove,

localstack_utils/localstack.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def startup(self, docker_configuration):
4343
pull_new_image=docker_configuration.pull_new_image,
4444
image_name=docker_configuration.image_name,
4545
image_tag=docker_configuration.image_tag,
46+
container_name=docker_configuration.container_name,
4647
gateway_listen=docker_configuration.gateway_listen,
4748
auto_remove=docker_configuration.auto_remove_container,
4849
environment_variables=docker_configuration.environment_variables,
@@ -71,6 +72,7 @@ def setup_logger(self):
7172
def startup_localstack(
7273
image_name="",
7374
tag="",
75+
container_name="",
7476
pro=False,
7577
ports=None,
7678
env_variables=None,
@@ -89,6 +91,9 @@ def startup_localstack(
8991
if tag:
9092
config.image_tag = tag
9193

94+
if container_name:
95+
config.container_name = container_name
96+
9297
if ports:
9398
config.port_mappings = ports
9499

localstack_utils/localstack_docker_configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class LocalstackDockerConfiguration:
33
randomize_ports = False
44
image_name = None
55
image_tag = None
6+
container_name = None
67
platform = None
78

89
gateway_listen = "0.0.0.0:4566"

0 commit comments

Comments
 (0)