Running DynamoDB Local with Docker
DynamoDB Local is the real DynamoDB engine in a single process — no AWS account, no network, no per-request bill. Use it for local development and integration tests, then point the same code at the cloud in production.
Start the container
docker run -p 8000:8000 amazon/dynamodb-localThat exposes the engine on http://localhost:8000.
docker-compose
Most projects pin it in docker-compose.yml so the whole team gets the same
endpoint:
services:
dynamodb:
image: amazon/dynamodb-local
command: '-jar DynamoDBLocal.jar -sharedDb -dbPath /data'
ports:
- '8000:8000'
volumes:
- dynamodb-data:/data
volumes:
dynamodb-data:Persistence
By default DynamoDB Local is in-memory — every table vanishes when the container stops. Two flags make it durable:
-sharedDbkeeps all clients on one shared database file (without it, each set of credentials/region gets its own isolated DB — a common "where did my table go?" surprise).-dbPath /data+ a mounted volume writes that file to disk, so data survivesdocker compose down.
Point the SDK at it
Only the endpoint changes — credentials can be any dummy values:
import {DynamoDBClient} from '@aws-sdk/client-dynamodb';
const client = new DynamoDBClient({
endpoint: 'http://localhost:8000',
region: 'local',
credentials: {accessKeyId: 'x', secretAccessKey: 'x'}
});Create a table
aws dynamodb create-table \
--endpoint-url http://localhost:8000 \
--table-name AppData \
--attribute-definitions AttributeName=PK,AttributeType=S AttributeName=SK,AttributeType=S \
--key-schema AttributeName=PK,KeyType=HASH AttributeName=SK,KeyType=RANGE \
--billing-mode PAY_PER_REQUESTA single-table PK/SK schema like this is a good
default. When you load fixtures, convert plain JSON to the wire format with the
DynamoDB-JSON converter.
Verify the container is up and the table landed:
aws dynamodb list-tables --endpoint-url http://localhost:8000Browse it with a GUI
CLI calls get tedious fast. The usual options are the open-source dynamodb-admin
web UI or a desktop client. DynoTable connects straight to
localhost:8000 (or any LocalStack endpoint — see
connecting to DynamoDB Local & LocalStack)
and lets you browse, query with the , and edit local tables with the
same UI you use for cloud tables — no aws CLI round-trips.