'Can not find table using NoSQL Workbench for DynamoDB when connecting to DynamoDB Docker

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?



Solution 1:[1]

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"

Solution 2:[2]

I had the same problem with using a docker container with docker-compose.

AWS has a documentation page here with the following snippet:

version: '3.8'
services:
  dynamodb-local:
    command: "-jar DynamoDBLocal.jar -sharedDb -optimizeDbBeforeStartup -dbPath ./data"
    image: "amazon/dynamodb-local:latest"
    container_name: dynamodb-local
    ports:
      - "8000:8000"
    volumes:
      - "./docker/dynamodb:/home/dynamodblocal/data"
    working_dir: /home/dynamodblocal

Using the above I was still unable to connect with NoSQL Workbench, so I tried using the AWS CLI to connect:

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

To get this working I had to do two things:

  1. Run aws configure because I was missing a region in my .aws credentials file.
  2. Use docker-compose up instead of docker-compose run. The run command does not expose ports.

After the AWS CLI was connecting the NoSQL Workbench connected successfully.

Solution 3:[3]

I know this old but I came to the same issue in where NoSQL Workbench wasn't getting the tables when working docker container the dynamodb image and solved it in a different way.

I've used this command to create the table:

aws dynamodb create-table --table-name Movies \ 
--key-schema AttributeName=year,KeyType=HASH \
AttributeName=title,KeyType=RANGE --attribute-definitions \ 
AttributeName=year,AttributeType=N \
AttributeName=title,AttributeType=S \
--provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=10 \
--billing-mode PROVISIONED \
--endpoint-url http://localhost:8000 \
--profile default

When creating the connection in the NoSQL Workbench I've noticed a callout that says "NoSQL Workbench uses the 'localhost' region when establishing a DynamoDB local connection.":

localhost-callout-image

Immediatly I remeber that when configuring the aws credentials I've never used localhost as a region. So what I did was to set localhost as a region, executed again the command to create the table and it start getting the information of table in the client.

Hope this can help someone.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Gabe Gates
Solution 3 Locojuhi