My docker compose file has two containers and looks like this
version: \'3\'
services:
dynamodb:
image: amazon/dynamodb-local
ports:
So that image use by default in-memory dynamodb (what you can find by running docker inspect on that image)
"CMD [\"-jar\" \"DynamoDBLocal.jar\" \"-inMemory\"]"
So if you want to keep your data you need to do something like this in you docker-compose:
version: '3'
volumes:
dynamodb_data:
services:
dynamodb:
image: amazon/dynamodb-local
command: -jar DynamoDBLocal.jar -sharedDb -dbPath /home/dynamodblocal/data/
volumes:
- dynamodb_data:/home/dynamodblocal/data
ports:
- "8000:8000"
To preserve data across docker installations create volume using docker.
docker volume create --driver local --opt type=none \
--opt device=/var/opt/dynamodb_data --opt o=bind dynamodb_data
use external
option:
version: "3"
volumes:
dynamodb_data:
external: true
services:
dynamodb-local:
image: amazon/dynamodb-local
command: ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-dbPath", "/home/dynamodblocal/data"]
volumes:
- dynamodb_data:/home/dynamodblocal/data
You can try this docker-compose config:
version: '3'
volumes:
dynamodb_data:
services:
dynamodb:
image: amazon/dynamodb-local
command: -jar DynamoDBLocal.jar -sharedDb -dbPath /home/dynamodblocal
volumes:
- dynamodb_data:/home/dynamodblocal
ports:
- "8000:8000"