Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / containers / docker

Run Amazon DynamoDB Locally with Docker

5.00/5 (2 votes)
30 Oct 2016CPOL1 min read 9.1K  
Run Amazon DynamoDB locally with Docker

Run Amazon DynamoDB locally with Docker

tl;dr: Run DynamoDB locally using Docker:

docker run -d -p 8000:8000 dwmkerr/dynamodb  

Try it out by opening the shell, localhost:8000/shell:

Run Amazon DynamoDB locally with Docker

That's all there is to it!

DynamoDB

Amazon DynamoDB is a NoSQL database-as-a-service, which provides a flexible and convenient repository for your services.

Building applications which use DynamoDB is straightforward, there are APIs and clients for many languages and platforms.

One common requirement is to be able to run a local version of DynamoDB, for testing and development purposes. To do this, you need to:

  1. Hit the DynamoDB Local documentation page
  2. Download an archive
  3. Extract it to a sensible location
  4. Run the extracted JAR, perhaps passing in some options

This can be a little cumbersome if you regularly use DynamoDB, so here's a easier way:

docker run -p 8000:8000 dwmkerr/dynamodb 

The dwmkerr/dynamodb image runs the JAR in a container, exposing the database on port 8000 by default.

You can see the image on the Docker Hub and the source code at github.com/dwmkerr/docker-dynamodb.

Customising DynamoDB

You can pass any of the documented commandline flags to DynamoDB. There are instructions on the GitHub page. Here's an example of how you can pass in a data directory, which allows DynamoDB data to be persisted after restarting a container (the image is ephemeral by default, as per Dockerfile best practices).

docker run -d -p 8000:8000 -v /tmp/data:/data/ dwmkerr/dynamodb -dbPath /data/  

Running DynamoDB in a container gives an extra degree of flexibility and can speed up your workflow too!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)