Set Up Local DynamoDB in a Docker Container

In this tutorial, I am going to show you how to set up a local DynamoDB in a Docker container so that you can play around with it on your local machine without any cost. Click here if you have not setup docker yet or here to setup AWS SDK to your environment.

Benefits of having a local DynamoDB instance

One of the benefits of having a local DynamoDB instance is that you can test your application code that interacts with DynamoDB locally instead of pointing to a real DynamoDB in AWS cloud. Not only it is free of charge but you also have full control of it moreover no need to worry about the provisioned throughput with the local instance.

Let’s get started! Please run below script to download Dynamodb container image from docker hub.

docker pull amazon/dynamodb-local

Execute below script to run docker DynamoDB container locally.

docker run -d -p 8000:8000 amazon/dynamodb-local

The above command runs the container in interactive mode. The container can be run in detached mode using the -d flag.
Now you can execute below script to access local Dynamodb JavaScript Shell on your web browser.


Run below script to list out all available tables in local Dynamodb using AWS SDK.

aws dynamodb list-tables --endpoint-url http://localhost:8000

Of course there would be no tables returned as this is a new installation and configuration. Now let’s create a new table then insert data into it.

aws dynamodb --endpoint-url http://localhost:8000 create-table --table-name mydemo `
--attribute-definitions AttributeName=custId,AttributeType=S --key-schema AttributeName=custId,KeyType=HASH `
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

mydemo table created successfully. Now let’s display all existing tables within Dynamodb.

aws dynamodb list-tables --endpoint-url http://localhost:8000

As you can see from above screenshot, mydemo table returned after the script executed successfully.

I hope this tutorial helps you understand how you can leverage the local DynamoDB Docker container image to do local testing of your application that uses DynamoDB. Remember this is free of charge.

Published by Jean Joseph

Jean Joseph is a Database, Big Data, Data Warehouse Platform, Data Pipeline, Database Architecture Solutions Provider as well as a Data Engineer enthusiast among other disciplines.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: