Ali Khakpouri
Ali Khakpouri

Reputation: 875

Connection to Dynamodb local in docker times out

I'm creating a new docker container named dynmodb using the following compose file.

    version: '3.8'
services:
  dynamodb-local:
    command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
    image: "amazon/dynamodb-local:latest"
    container_name: dynamodb
    ports:
      - "8000:8000"
    volumes:
      - "./data/dynamodb:/home/dynamodblocal/data"
    working_dir: /home/dynamodblocal
  dynamodb-init:
    depends_on:
      - dynamodb-local
    image: amazon/aws-cli
    environment:
      AWS_ACCESS_KEY_ID: dummy-key-id
      AWS_SECRET_ACCESS_KEY: dummy-key
    command: >-
      dynamodb create-table
        --table-name Foo
        --attribute-definitions
            AttributeName=id,AttributeType=S
        --key-schema
            AttributeName=id,KeyType=HASH
        --billing-mode PAY_PER_REQUEST
        --endpoint-url http://dynamodb-local:8000 --region dummy-region

When all set & done after running `docker compose up -d` my container is up & running and the tcp port is listed as following:
CONTAINER ID   IMAGE                          COMMAND                  CREATED          STATUS          PORTS                                       NAMES
7f8b152c7ea8   amazon/dynamodb-local:latest   "java -jar DynamoDBL…"   14 seconds ago   Up 11 seconds   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp   dynamodb

when I try to list-tables in this database, I use the following aws-cli statement.

aws dynamodb list-tables --endpoint http://localhost:8000 --profile akhakpouri

After a while, I get the timeout exception stating "Read timeout on endpoint URL: "http://localhost:8000/""

What can I do to fix this problem?

Upvotes: 0

Views: 75

Answers (1)

J-Jacques M
J-Jacques M

Reputation: 1118

Have you try like that ?

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

....

Upvotes: 0

Related Questions