Docker Compose facilitates spinning up local AWS-compatible services without an AWS account. This post covers DynamoDB Local for key-value storage and ElasticMQ for an SQS-compatible message queue. A common pattern is to persist state in DynamoDB and notify workers through SQS.
Prerequisites
- Docker Compose installed
Configuration
The following configuration spins up DynamoDB Local, DynamoDB Admin, ElasticMQ, and the ElasticMQ UI.
Connection details:
- DynamoDB endpoint:
http://localhost:8000 - SQS endpoint:
http://localhost:9324 - DynamoDB Admin:
http://localhost:8001 - ElasticMQ UI:
http://localhost:3000 - Region:
us-east-1 - Credentials: any dummy values (for example
local/local)
# docker-compose.yml
services:
dynamodb:
image: amazon/dynamodb-local:latest
user: root
command: '-jar DynamoDBLocal.jar -sharedDb -dbPath /home/dynamodblocal/data'
ports:
- '8000:8000'
volumes:
- dynamodb_data:/home/dynamodblocal/data
dynamodb-admin:
image: aaronshaf/dynamodb-admin:latest
ports:
- '8001:8001'
environment:
DYNAMO_ENDPOINT: http://dynamodb:8000
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: local
AWS_SECRET_ACCESS_KEY: local
depends_on:
- dynamodb
elasticmq:
image: softwaremill/elasticmq-native:latest
ports:
- '9324:9324'
volumes:
- ./elasticmq.conf:/opt/elasticmq.conf
- elasticmq_data:/data
elasticmq-ui:
image: softwaremill/elasticmq-ui:latest
ports:
- '3000:3000'
environment:
SQS_ENDPOINT: http://elasticmq:9324
depends_on:
- elasticmq
volumes:
dynamodb_data:
elasticmq_data:
ElasticMQ loads queue definitions from an elasticmq.conf file included in the demo.
Run the following command to spin up the containers.
docker compose up -d
Disclaimer
ElasticMQ provides an SQS-compatible API, but it is not AWS SQS. DynamoDB Local also differs from managed DynamoDB (for example capacity modes, streams, TTL, and global tables). Use these containers for local development and integration tests, not as production substitutes.
Demo
Docker Compose files and scripts for this post live in the dynamodb-sqs-docker-compose folder. Get access via code demos.
Top comments (0)