I've started DynamoDB in Docker:
docker run --network xxx --name dynamodb -d -p 8000:8000 amazon/dynamodb-local
I've created a table:
aws dynamodb create-table --table-name test --attribute-definitions \
AttributeName=UUID,AttributeType=S \
--key-schema AttributeName=UUID,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 --endpoint-url http://localhost:8000
List the table:
aws dynamodb list-tables --endpoint-url http://localhost:8000
{
"TableNames": [
"test"
]
}
I'm able to connect to it using localhost:8000
. Now I've installe NoSQL Workbench for Amazon DynamoDB. I checked operation builder and added the connection for a local dynamoDB. I've searched for tables (test) but I can not find anything? What am I doing wrong?
In Amazon DynamoDB, you can use either the DynamoDB API, or PartiQL, a SQL-compatible query language, to add an item to a table. With the DynamoDB API, you use the PutItem operation to add an item to a table. The primary key for this table consists of Artist and SongTitle. You must specify values for these attributes.
The key to make it work is to use the -sharedDB
flag, as detailed here.
Unfortunately, adding only that one key would cause container to exit right after start, I believe the reason is that by providing one flag it overwrites all the standard ones.
To obviate the problem I just supply all the standard ones and it works:
docker run -p 8000:8000 -d amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb -dbPath .
With docker-compose
you can do the same as follows:
version: '3'
services:
local-dynamo:
image: amazon/dynamodb-local
command: -jar DynamoDBLocal.jar -sharedDb -dbPath .
ports:
- "8000:8000"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With