DEV Community

Ibrar Hussain
Ibrar Hussain

Posted on • Originally published at Medium

Setup DynamoDB Docker Container for Local Development

DynamoDB is a powerful NoSQL database service provided by AWS. If you're developing applications that use DynamoDB, having a local environment for testing is crucial. Docker makes setting up a local DynamoDB instance for your development needs easy.

Install Docker Desktop

If you don't have Docker Desktop installed, follow these steps:

  • Download Docker Desktop:
    Visit the Docker Desktop website and download the appropriate version for your operating system.

  • Install Docker Desktop:
    Follow the installation instructions for your operating system.

Set Up DynamoDB with Docker

  • Create a Folder:
mkdir docker-workspace
Enter fullscreen mode Exit fullscreen mode
  • Navigate to the Folder:
cd docker-workspace
Enter fullscreen mode Exit fullscreen mode
  • Create a Docker Compose File:
touch docker-compose.yml
Enter fullscreen mode Exit fullscreen mode
  • Open docker-compose.yml and Add the Following Content:
version: "3.7"
  # DynamoDB Server
    command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
    image: "amazon/dynamodb-local:latest"
    container_name: dynamodb
      - "8000:8000"
      - "./docker/dynamodb:/home/dynamodblocal/data"
    working_dir: /home/dynamodblocal
      - docker_workspace_network

Enter fullscreen mode Exit fullscreen mode
  • Save and Close the File.

  • Start Docker Containers:

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Access DynamoDB Local Console

Once the Docker container is up and running, you can access the DynamoDB interface by downloading AWS NoSQL Workbench here for your operating system. Follow the instructions here for installation. On successful installation, you can add a new connection in the Operation builder section for your DynamoDB local.

Using DynamoDB in Your Application

Now that you have a local DynamoDB instance running, you can configure your application (in my case Laravel application) to use it. Update your application's DynamoDB configuration to point to localhost:8000.

Enter fullscreen mode Exit fullscreen mode

With this setup, you can develop and test your application locally with DynamoDB.

Refer to the official DynamoDB Local documentation for more advanced configurations and details.

Happy coding!

Top comments (0)