Skip to content

Commit 47a6997

Browse files
committed
Support for volumes on container start
1 parent 048e63b commit 47a6997

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pytest_localstack/session.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,21 +317,26 @@ def start(self, timeout=60):
317317
"USE_SSL": use_ssl,
318318
}
319319

320-
if self.persistent:
321-
environment['DATA_DIR'] = '/tmp/localstack/data'
322-
323320
try:
324321
_container = self.docker_client.containers.get(self.container_name)
325322
_container.start()
326323
self._container = _container
327324
except (docker.errors.NotFound, docker.errors.APIError):
325+
if self.persistent:
326+
host_data_dir = '/tmp/localstack/data'
327+
container_data_dir = '/tmp/localstack_data'
328+
environment['DATA_DIR'] = host_data_dir
329+
328330
self._container = self.docker_client.containers.run(
329331
image_name,
330332
name=self.container_name,
331333
detach=True,
332334
auto_remove=self.auto_remove,
333335
environment=environment,
334336
ports={port: None for port in self.services.values()},
337+
volumes={
338+
host_data_dir: {'bind': container_data_dir, 'mode': 'rw'},
339+
},
335340
)
336341
logger.debug(
337342
"Started Localstack container %s (id: %s)",

0 commit comments

Comments
 (0)