How to persist data in a dockerized DynamoDB using volumes

后端 未结 3 766
南旧
南旧 2021-02-02 14:36

My docker compose file has two containers and looks like this

  version: \'3\'

  services:
     dynamodb:
       image: amazon/dynamodb-local
       ports: 
            


        
3条回答
  •  日久生厌
    2021-02-02 15:16

    So that image use by default in-memory dynamodb (what you can find by running docker inspect on that image)

    "CMD [\"-jar\" \"DynamoDBLocal.jar\" \"-inMemory\"]"
    

    So if you want to keep your data you need to do something like this in you docker-compose:

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

提交回复
热议问题