Skip to content

Commit b87da50

Browse files
klcodanrDan Klco
andauthored
Adding dockerRemove option to remove the container after stopping the database (#7)
Co-authored-by: Dan Klco <klco@adobe.com>
1 parent acbd437 commit b87da50

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ interface StartOptions {
9797
/** If docker enabled, docker image to run. @default "amazon/dynamodb-local" */
9898
dockerImage: string,
9999

100+
/** If docker enabled, remove the container after stopping. @default false */
101+
dockerRemove: boolean,
102+
100103
/** Folder where DynamoDB Local is installed to. @default ".dynamodb" */
101104
installPath: string,
102105

src/start.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export interface StartOptions {
4747
/** If docker enabled, docker image to run. @default "amazon/dynamodb-local" */
4848
dockerImage: string,
4949

50+
/** If docker enabled, remove the container after stopping. @default false */
51+
dockerRemove: boolean,
52+
5053
/** Folder where DynamoDB Local is installed to. @default ".dynamodb" */
5154
installPath: string,
5255

@@ -68,6 +71,7 @@ const defaultOptions: StartOptions = {
6871
docker: false,
6972
dockerPath: 'docker',
7073
dockerImage: 'amazon/dynamodb-local',
74+
dockerRemove: false,
7175
installPath: defaultInstallPath,
7276
install_path: undefined,
7377
};
@@ -115,7 +119,11 @@ export const start = async (customOptions?: Partial<StartOptions>): Promise<void
115119
}
116120

117121
const commonArgs = ['-jar', jarFilename, '-port', String(options.port)];
118-
const dockerArgs = ['run', '-p', `${options.port}:${options.port}`, options.dockerImage];
122+
const dockerArgs = ['run', '-p', `${options.port}:${options.port}`];
123+
if(options.dockerRemove) {
124+
dockerArgs.push('-rm');
125+
}
126+
dockerArgs.push(options.dockerImage);
119127
if (options.install_path) {
120128
deprecation('Use installPath instead of install_path');
121129
}

0 commit comments

Comments
 (0)