{"id":17196,"date":"2018-09-15T09:00:16","date_gmt":"2018-09-15T00:00:16","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=17196"},"modified":"2018-11-29T13:35:54","modified_gmt":"2018-11-29T04:35:54","slug":"dynamodb-local-docker","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2018\/09\/15\/dynamodb-local-docker\/","title":{"rendered":"DynamoDB Local\u306eDocker\u30a4\u30e1\u30fc\u30b8\u3092\u89e6\u3063\u3066\u307f\u308b"},"content":{"rendered":"<p>\u3064\u3044\u5148\u65e5\u306e8\u670822\u65e5\u306b\u3001Amazon\u304b\u3089\u516c\u5f0f\u306bDynamoDB\u306eDocker\u30a4\u30e1\u30fc\u30b8\u304c\u516c\u958b\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/aws.amazon.com\/jp\/about-aws\/whats-new\/2018\/08\/use-amazon-dynamodb-local-more-easily-with-the-new-docker-image\/\">\u65b0\u3057\u3044\u30c9\u30c3\u30ab\u30fc\u30a4\u30e1\u30fc\u30b8\u3067 Amazon DynamoDB \u30ed\u30fc\u30ab\u30eb\u3092\u3055\u3089\u306b\u5bb9\u6613\u306b<\/a>\n<\/li>\n<li><a href=\"https:\/\/hub.docker.com\/r\/amazon\/dynamodb-local\/\">amazon\/dynamodb-local - Docker Hub<\/a>\n<\/li>\n<\/ul>\n<p>\u3061\u3087\u3046\u3069DynamoDB Local\u3092\u5229\u7528\u3057\u3066\u3044\u305f\u3068\u3053\u308d\u3060\u3063\u305f\u306e\u3067\u3001\u65e9\u901f\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h2>\u3068\u308a\u3042\u3048\u305a\u7acb\u3061\u4e0a\u3052\u308b<\/h2>\n<pre><code class='code-multiline'>$ docker run --rm amazon\/dymamodb-local\nInitializing DynamoDB Local with the following configuration:\nPort:   8000\nInMemory:   true\nDbPath: null\nSharedDb:   false\nshouldDelayTransientStatuses:   false\nCorsParams: *<\/code><\/pre>\n<p>jar\u3067\u914d\u5e03\u3055\u308c\u3066\u3044\u305f\u3082\u306e\u3068\u540c\u3058\u3088\u3046\u3067\u3059\u306d\u3002<br \/>\n<a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/amazondynamodb\/latest\/developerguide\/DynamoDBLocal.html\">DynamoDB \u30ed\u30fc\u30ab\u30eb (\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\u80fd\u30d0\u30fc\u30b8\u30e7\u30f3) \u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7 - Amazon DynamoDB<\/a><\/p>\n<h2>\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u305f\u3044<\/h2>\n<p>\u3068\u308a\u3042\u3048\u305a\u958b\u767a\u6642\u306e\u30c6\u30b9\u30c8\u306e\u305f\u3081\u3001\u30c7\u30fc\u30bf\u3092\u6c38\u7d9a\u5316\u3057\u305f\u3044\u3067\u3059\u3002<br \/>\njar\u7248\u3067\u306f\u8d77\u52d5\u6642\u306e\u5f15\u6570\u3067\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u304c\u3001Docker\u30a4\u30e1\u30fc\u30b8\u306b\u304a\u3044\u3066\u3082\u5f15\u6570\u3092\u6e21\u305b\u308c\u3070\u8a2d\u5b9a\u3067\u304d\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>Dockerfile\u306f\u898b\u5f53\u305f\u3089\u306a\u3044\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305ainspect\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code class='code-multiline'>$ docker inspect amazon\/dynamodb-local:latest\n(snip)\n        \"Config\": {\n            \"Hostname\": \"\",\n            \"Domainname\": \"\",\n            \"User\": \"dynamodblocal\",\n            \"AttachStdin\": false,\n            \"AttachStdout\": false,\n            \"AttachStderr\": false,\n            \"ExposedPorts\": {\n                \"8000\/tcp\": {}\n            },\n            \"Tty\": false,\n            \"OpenStdin\": false,\n            \"StdinOnce\": false,\n            \"Env\": [\n                \"PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\"\n            ],\n            \"Cmd\": [\n                \"-jar\",\n                \"DynamoDBLocal.jar\",\n                \"-inMemory\"\n            ],\n            \"ArgsEscaped\": true,\n            \"Image\": \"sha256:6901b80d033a1d94e1283711be031f2657d90edf0768118bb22c952feba780bd\",\n            \"Volumes\": null,\n            \"WorkingDir\": \"\/home\/dynamodblocal\",\n            \"Entrypoint\": [\n                \"java\"\n            ],\n            \"OnBuild\": null,\n            \"Labels\": {\n                \"aws.java.sdk.version\": \"1.11.119\"\n            }\n        },\n(snip)<\/code><\/pre>\n<ul>\n<li>Entrypoint: java\n<\/li>\n<li>Cmd: -jar DynamoDBLocal.jar -inMemory\n<\/li>\n<\/ul>\n<p>\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u306e\u3067\u3001docker run\u306e\u969b\u306b java\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u306a\u308b\u90e8\u5206\u3092\u3059\u3079\u3066\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u8a2d\u5b9a\u3092\u5909\u3048\u3089\u308c\u305d\u3046\u3067\u3059\u3002<\/p>\n<h2>\u30c7\u30fc\u30bf\u3092\u6c38\u7d9a\u5316\u3059\u308b<\/h2>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f<code>inMemory<\/code>\u3067\u8d77\u52d5\u3059\u308b\u306e\u3067\u3001\u30b3\u30f3\u30c6\u30ca\u3092\u7d42\u4e86\u3057\u305f\u5834\u5408\u306b\u306f\u30c7\u30fc\u30bf\u3082\u6d88\u3048\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u30af\u30ea\u30fc\u30f3\u306a\u74b0\u5883\u3067\u30c6\u30b9\u30c8\u3092\u884c\u3046\u3088\u3046\u306a\u5834\u5408\u306b\u306f\u305d\u308c\u3067\u3082\u304b\u307e\u3044\u307e\u305b\u3093\u304c\u3001\u666e\u6bb5\u306e\u958b\u767a\u4e2d\u306b\u306f\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u3084\u30c7\u30fc\u30bf\u306e\u6e96\u5099\u306a\u3069\u3092\u6bce\u56de\u884c\u3044\u305f\u304f\u306f\u3042\u308a\u307e\u305b\u3093\u306e\u3067\u3001\u30c7\u30fc\u30bf\u3092\u6c38\u7d9a\u5316\u3057\u3066\u304a\u3044\u305f\u307b\u3046\u304c\u697d\u306a\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>dbPath\u3067\u30d1\u30b9\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3001Volume\u3092\u6307\u5b9a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30db\u30b9\u30c8\u5074: ~\/dynamodb-data<\/li>\n<li>\u30b3\u30f3\u30c6\u30ca\u5074: \/home\/dynamodblocal\/data<\/li>\n<\/ul>\n<p>\u3072\u3068\u307e\u305a\u30d5\u30a9\u30a2\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre><code class='code-multiline'>$ docker run --rm -p 8000:8000 -v ~\/dynamodb-data:\/home\/dynamodblocal\/data \\\namazon\/dynamodb-local -jar DynamoDBLocal.jar -dbPath \/home\/dynamodblocal\/data\nInitializing DynamoDB Local with the following configuration:\nPort:   8000\nInMemory:   false\nDbPath: \/home\/dynamodblocal\/data\nSharedDb:   false\nshouldDelayTransientStatuses:   false\nCorsParams: *<\/code><\/pre>\n<p>\u5225\u306e\u30bf\u30fc\u30df\u30ca\u30eb\u304b\u3089aws\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3001\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code class='code-multiline'>$ aws dynamodb create-table --table-name Clients \\\n    --attribute-definitions AttributeName=id,AttributeType=S \\\n    --key-schema AttributeName=id,KeyType=HASH \\\n    --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \\\n    --endpoint-url http:\/\/localhost:8000\n{\n    \"TableDescription\": {\n        \"TableArn\": \"arn:aws:dynamodb:ddblocal:000000000000:table\/Clients\",\n(snip)\n    }\n}<\/code><\/pre>\n<p>\u4e00\u89a7\u3067\u53d6\u5f97\u3067\u304d\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre><code class='code-multiline'>$ aws dynamodb list-tables --endpoint-url http:\/\/localhost:8000\n{\n    \"TableNames\": [\n        \"Clients\"\n    ]\n}<\/code><\/pre>\n<p>\u30c7\u30fc\u30bf\u306e\u4fdd\u5b58\u5148\u306b\u6307\u5b9a\u3057\u305f\u5834\u6240\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code class='code-multiline'>$ ls ~\/dynamodb-data\nAKIAIOSFODNN7EXAMPLE_ap-northeast-1.db<\/code><\/pre>\n<p>\u3053\u306e\u4e2d\u306b\u30c7\u30fc\u30bf\u304c\u5165\u3063\u3066\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u7c21\u5358\u3067\u3059\u304cDocker\u30a4\u30e1\u30fc\u30b8\u3067\u306eDynamoDB Local\u306e\u52d5\u4f5c\u78ba\u8a8d\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>Java\u3092\u666e\u6bb5\u304b\u3089\u4f7f\u7528\u3057\u3066\u3044\u308b\u65b9\u306b\u3068\u3063\u3066\u306fjar\u7248\u306e\u65b9\u304c\u3066\u3063\u3068\u308a\u65e9\u3044\u6c17\u304c\u3057\u307e\u3059\u3002<br \/>\nJava\u4ee5\u5916\u306e\u8a00\u8a9e\u3092\u4f7f\u3063\u3066\u3044\u3066\u308b\u4eba\u306b\u3068\u3063\u3066\u306f\u3001Java\u306e\u74b0\u5883\u3092\u7528\u610f\u3057\u306a\u304f\u3066\u3082\u52d5\u4f5c\u304c\u3067\u304d\u308b\u306e\u306f\u697d\u306b\u306a\u3063\u305f\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u3001\u3046\u307e\u304f\u6d3b\u7528\u3057\u305f\u3044\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3064\u3044\u5148\u65e5\u306e8\u670822\u65e5\u306b\u3001Amazon\u304b\u3089\u516c\u5f0f\u306bDynamoDB\u306eDocker\u30a4\u30e1\u30fc\u30b8\u304c\u516c\u958b\u3055\u308c\u307e\u3057\u305f\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2018\/09\/15\/dynamodb-local-docker\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[137],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/17196"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=17196"}],"version-history":[{"count":8,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/17196\/revisions"}],"predecessor-version":[{"id":17289,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/17196\/revisions\/17289"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=17196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=17196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=17196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}