-
-
Save cmackenzie1/92e0c3628da6842f0e9ffeca8abbe170 to your computer and use it in GitHub Desktop.
| version: '3.7' | |
| services: | |
| dynamodb-local: | |
| image: amazon/dynamodb-local:latest | |
| container_name: dynamodb-local | |
| ports: | |
| - "8000:8000" | |
| dynamodb-admin: | |
| image: aaronshaf/dynamodb-admin | |
| ports: | |
| - "8001:8001" | |
| environment: | |
| DYNAMO_ENDPOINT: "http://dynamodb-local:8000" | |
| AWS_REGION: "us-west-2" | |
| AWS_ACCESS_KEY_ID: local | |
| AWS_SECRET_ACCESS_KEY: local | |
| depends_on: | |
| - dynamodb-local |
@cmackenzie1 Can you let me know why we have to specifying
DYNAMO_ENDPOINTinstead oflocalhost? Sorry Im a newbie.
No worries! I specified DYNAMO_ENDPOINT due to how Docker Compose creates networks. The Docker docs have a good overview of what it does when using docker-compose https://docs.docker.com/compose/networking/.
The tl;dr is localhost doesn't always resolve to your actual local machine network adapter.
@cmackenzie1 Can you let me know why we have to specifying
DYNAMO_ENDPOINTinstead oflocalhost? Sorry Im a newbie.No worries! I specified
DYNAMO_ENDPOINTdue to how Docker Compose creates networks. The Docker docs have a good overview of what it does when usingdocker-composehttps://docs.docker.com/compose/networking/.The tl;dr is
localhostdoesn't always resolve to your actual local machine network adapter.
Thank you so much for you explanation. 😊
Double check the region matches and you set some local credentials (and use them in the SDK in addition to the endpoint parameter.)
@cmackenzie1 What should the region match to? Does this relate to the region we set up in aws configure or... ?
@mxmzb it would depend on your specific setup. The AWS SDK (in the language of your choice) should at least specify the same region as the configured Docker container.
If you are relying on profiles in your ~/.aws/credentials file, then the region for the selected profile would need to match.
I was unable to see tables created by different scripts until I enabled sharedDb mode.
Note the command property...
version: '3.9'
services:
dynamodb:
image: amazon/dynamodb-local:2.4.0
command: "-jar DynamoDBLocal.jar -sharedDb"
healthcheck:
test: [ "CMD-SHELL", "curl -v http://dynamodb:8000" ]
interval: 3s
timeout: 3s
retries: 5
start_period: 3s
ports:
- "8000:8000"
restart: always
dynamodb-admin:
image: aaronshaf/dynamodb-admin:4.6.1
ports:
- "8001:8001"
environment:
DYNAMO_ENDPOINT: "http://dynamodb:8000"
AWS_REGION: "eu-west-2"
AWS_ACCESS_KEY_ID: abc
AWS_SECRET_ACCESS_KEY: def
depends_on:
dynamodb:
condition: service_healthy
@cmackenzie1 Can you let me know why we have to specifying
DYNAMO_ENDPOINTinstead oflocalhost? Sorry Im a newbie.