1

I'm starting a springboot app and dynamodb local in docker containers via docker-compose.

Both containers come up successfully.

When I use the container name for the AMAZON_AWS_DYNAMODB_ENDPOINT value, I get the following error:

[https-jsse-nio-8443-exec-6] [2019-04-15 08:03:42,239] INFO   com.amazonaws.protocol.json.JsonContent [] - Unable to parse HTTP response content
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (byte[])"<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://aws.amazon.com/dynamodb/">here</a>.</p>
</body></html>

Further down I'm getting the following error:

com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: null (Service: AmazonDynamoDBv2; Status Code: 301; Error Code: null; Request ID: null)

If I replace the AMAZON_AWS_DYNAMODB_ENDPOINT value with my Windows computer IP address (running the containers) it works successfully.

Any suggestions on how to get the container name working?

Here's my docker-compose:

version: '3'
services:
  dynamodb:
    image: amazon/dynamodb-local
    ports:
      - "8000:8000"
    volumes:
      - dynamodata:/data
    command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ."

  app:
    build: .
    ports:
      - "8443:8443"

    environment:
      - SERVER_PORT=8443
      - SERVER_SSL_KEY_STORE=/etc/ssl/key
      - SERVER_SSL_KEY_STORE_TYPE=PKCS12
      - SERVER_SSL_KEY_ALIAS=tomcat
      - SERVER_SSL_KEY_STORE_PASSWORD=xxxxxx
      - SPRING_PROFILES_ACTIVE=aws,local
      - DATAPOWER_ENABLED=true
#      - AMAZON_AWS_DYNAMODB_ENDPOINT=${DYNAMODB_ENDPOINT:-http://dynamodb:8000}  <--- does not work
#      - AMAZON_AWS_DYNAMODB_ENDPOINT=${DYNAMODB_ENDPOINT:-http://xx.xxx.xxx.xxx:8000}  <--- works
      - AMAZON_AWS_DYNAMODB_REGION=${DYNAMODB_REGION:-us-east-1}
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-local}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-xxxxxxxxxx}
      - ENV=dev
      - AWS_REGION=us-east-1

volumes:
  dynamodata:

Thanks

JonathanSK
  • 81
  • 2
  • 6

1 Answers1

1

Try adding networks something like this:

version: '3'
services:
  dynamodb:
    image: amazon/dynamodb-local
    ports:
      - "8000:8000"
    volumes:
      - dynamodata:/data
    command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ."
    networks:
      - my-network

  app:
    build: .
    ports:
      - "8443:8443"

    environment:
      - SERVER_PORT=8443
      - SERVER_SSL_KEY_STORE=/etc/ssl/key
      - SERVER_SSL_KEY_STORE_TYPE=PKCS12
      - SERVER_SSL_KEY_ALIAS=tomcat
      - SERVER_SSL_KEY_STORE_PASSWORD=xxxxxx
      - SPRING_PROFILES_ACTIVE=aws,local
      - DATAPOWER_ENABLED=true
#      - AMAZON_AWS_DYNAMODB_ENDPOINT=${DYNAMODB_ENDPOINT:-http://dynamodb:8000}  <--- does not work
#      - AMAZON_AWS_DYNAMODB_ENDPOINT=${DYNAMODB_ENDPOINT:-http://xx.xxx.xxx.xxx:8000}  <--- works
      - AMAZON_AWS_DYNAMODB_REGION=${DYNAMODB_REGION:-us-east-1}
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-local}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-xxxxxxxxxx}
      - ENV=dev
      - AWS_REGION=us-east-1
    networks:
      - my-network

volumes:
  dynamodata:

networks:
  my-network:
    driver: bridge
dk7
  • 678
  • 2
  • 10
  • 26