Q:

DynamoDB Local with docker-compose not working

I'm trying to run docker-compose with rabbit and dynamodb local
When I run dynamodb local by command line it works fine, the command that I use is:
docker run -p 8000:8000 --name=dynamodb -v D:/volumes/dynamodb:/data/ -e AWS_ACCESS_KEY_ID=root -e AWS_SECRET_ACCESS_KEY=pass -e AWS_REGION=us-east-1 amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb -dbPath /data

But when I try to run with docker compose I get the following error:
λ docker logs dynamodb
Unrecognized option: -jar DynamoDBLocal.jar -sharedDb -dbPath /data
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I tried the command like:

-jar DynamoDBLocal.jar -sharedDb -dbPath /data
java -jar DynamoDBLocal.jar -sharedDb -dbPath /data
-jar DynamoDBLocal.jar -sharedDb -dbPath .data
java -jar DynamoDBLocal.jar -sharedDb -dbPath .data

But, when I run with "java" in the begginning the error is:
Error: Could not find or load main class java -jar DynamoDBLocal.jar -sharedDb -dbPath

I tried differente ways to use volume and with version 2, but none worked
I tried to do what's described in:

How to fix dynamodb local call using docker-compose
https://github.com/ykrevnyi/docker-dynamodb-local/blob/master/docker-compose.yml
How to fix dynamodb local call using docker-compose
How to persist data in a dockerized DynamoDB using volumes

I'm using docker (not toolbox) and Win10
My docker-compose file is:
version: "3"

  services:

    rabbit:
      container_name: rabbitmq
      image: rabbitmq:3-management
      ports:
        - "5672:5672"
        - "15672:15672"
      healthcheck:
        test: ["CMD", "rabbitmqctl", "node_health_check"]
        interval: 2s
        timeout: 3s
        retries: 30

    dynamodb:
      container_name: dynamodb
      image: amazon/dynamodb-local:latest
      ports:
        - "8000:8000"
      volumes:
        - ./volumes/dynamodb:/data/
      environment:
        AWS_ACCESS_KEY_ID: root
        AWS_SECRET_ACCESS_KEY: pass
        AWS_REGION: us-east-1
      command: ["java -jar DynamoDBLocal.jar -sharedDb -dbPath ./data"]

A:

You either write your command in the exec form (i.e. as a list of elements) or in the shell form (i.e. as a single string) but you cannot mix both... or you get the error you just had. Choose either of the following
command: "java -jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
command: ["java", "-jar", "DynamoDBLocal.jar", "-sharedDb", "-dbPath", "./data"]

Reference: CMD instruction for Dockerfile

