How to persist data in a dockerized DynamoDB using volumes

后端 未结 3 764
南旧
南旧 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:17

    To preserve data across docker installations create volume using docker.

    docker volume create --driver local --opt type=none \
        --opt device=/var/opt/dynamodb_data --opt o=bind dynamodb_data
    

    use external option:

    version: "3"
    volumes: 
      dynamodb_data:
        external: true
    services:
      dynamodb-local:
        image: amazon/dynamodb-local
        command: ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-dbPath", "/home/dynamodblocal/data"]
        volumes:
          - dynamodb_data:/home/dynamodblocal/data
    

提交回复
热议问题