Search code examples
dockeramazon-dynamodbamazon-dynamodb-local

Change amazon/dynamodb-local Port


How can I change the port dynamodb starts on through the Amazon Docker image?

According to this answer, the -port option can be used when executing the dynamodb java file.

However, when running the docker image with this command: docker run -p 8000:8000 amazon/dynamodb-local I do not have the option of specifying the port dynamodb listens to, just the port connected between my host and the container.

Would I have to make my own Dockerfile, specifying the OS and installing dynamodb and whatnot, so I can run the java command and specify my port?


Solution

  • I tried the official image to override entry point but there was some unknown error, But you can good to go with this approach. Just create a New Docker image from amazon/dynamodb-local as a base image. Build.

    docker build -t mydb .
    

    and run it

    docker run -it --rm -p 8001:8001 mydb
    

    Below is the Dockerfile

    FROM amazon/dynamodb-local
    WORKDIR /home/dynamodblocal
    ENTRYPOINT ["java", "-jar", "DynamoDBLocal.jar", "-port", "8003"]
    

    As you will see the port.

    enter image description here