{"id":1685,"date":"2021-08-20T11:38:36","date_gmt":"2021-08-20T02:38:36","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=1685"},"modified":"2026-01-30T19:07:52","modified_gmt":"2026-01-30T10:07:52","slug":"%e3%80%90docker%e3%80%91%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab-docker-lambda%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=1685","title":{"rendered":"\u3010docker\u3011\u30ed\u30fc\u30ab\u30eb docker Lambda\u74b0\u5883\u69cb\u7bc9"},"content":{"rendered":"\n<p>docker\u3092\u4f7f\u7528\u3057\u3066\u30ed\u30fc\u30ab\u30eb\u306bLambda\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002<br>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306f Node.js \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>docker\u3001aws lambda\u306e\u57fa\u672c\u3092\u77e5\u3063\u3066\u3044\u308b\u524d\u63d0\u3068\u3057\u307e\u3059\u3002<br>\u307e\u305f\u3001\u30ed\u30fc\u30ab\u30ebPC\u306b\u306fdocker\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u3082\u306e\u3068\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210<\/h1>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210\u3068\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>02_sample_app\n   -- index.js\n03_platform\n   -- docker-compose.yml<\/code><\/pre><\/div>\n\n\n\n<p>index.js\u3001docker-compose.yml\u3092\u4f5c\u6210\u3057Lambda\u95a2\u6570\u306e\u7c21\u5358\u306a\u52d5\u4f5c\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">docker-compose.yml<\/h1>\n\n\n\n<p>docker-compose.yml\u306e\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>version: &#39;3.5&#39;\nservices:\n\n  sample_lambda:\n    container_name: sample_lambda\n    image: lambci\/lambda:nodejs12.x\n    tty: true\n    volumes:\n      - ..\/02_sample_app:\/var\/task\n      - .\/opt:\/opt\n    ports:\n      - 9001:9001\n    environment:\n      DOCKER_LAMBDA_STAY_OPEN: 1\n      DOCKER_LAMBDA_WATCH: 1\n      DOCKER_LAMBDA_DEBUG: 1\n      TZ: &#39;Asia\/Tokyo&#39;\n    command: index.handler<\/code><\/pre><\/div>\n\n\n\n<p>container_name\u306f\u4efb\u610f\u3067\u5909\u66f4\u3057\u3066\u4e0b\u3055\u3044\u3002\u30dd\u30fc\u30c8\u756a\u53f7\u3082\u4f7f\u7528\u3057\u3066\u3044\u306a\u3044\u30dd\u30fc\u30c8\u756a\u53f7\u3092\u6307\u5b9a\u3057\u3066\u4e0b\u3055\u3044\u3002<br>volumes: \u306b\u4ee5\u4e0b\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u6307\u5b9a\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306eindex.js\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br>environment: \u306e\u8aac\u660e\u306f\u7533\u3057\u8a33\u3054\u3056\u3044\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">index.js<\/h1>\n\n\n\n<p>event\u306e\u5185\u5bb9\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const aws = require(&quot;aws-sdk&quot;);\n\nexports.handler = async (event, context) =&gt; {\n    context.succeed({\n        statusCode: 200,\n        body      : event,\n    });\n};<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u547c\u3073\u51fa\u3057<\/h1>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306bhttp\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u3066\u78ba\u8a8d\u304c\u884c\u3048\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>curl -d &#39;{&quot;test&quot;:1}&#39; http:\/\/localhost:9001\/2015-03-31\/functions\/sample\/invocations<\/code><\/pre><\/div>\n\n\n\n<p>\u547c\u3073\u51fa\u3059URL\u306e\u30d1\u30b9\u306b\u3064\u3044\u3066\u4ee5\u4e0b\u3092\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u30fbfunctions \u307e\u3067\u306f\u304a\u6c7a\u307e\u308a\u3067\u3059\u3002\u56fa\u5b9a\u3068\u306a\u308a\u307e\u3059\u3002<br>\u30fbsample \u90e8\u5206\u306f\u4efb\u610f\u3067\u3059\u3002&#8221;sample&#8221;\u3067\u306a\u304f &#8220;a&#8221; \u3068\u3057\u3066\u3082\u547c\u3073\u51fa\u305b\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u306a\u3044\u3068\u547c\u3073\u51fa\u3057\u306e\u53cd\u5fdc\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u4f55\u304b\u6587\u5b57\u3092\u3064\u3051\u3066\u4e0b\u3055\u3044\u3002<br>\u30fbinvocations \u306f\u304a\u6c7a\u307e\u308a\u3067\u3059\u3002\u56fa\u5b9a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u7d50\u679c<\/h1>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u8fd4\u5374\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{&quot;statusCode&quot;:200,&quot;body&quot;:{&quot;test&quot;:1}}<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u6700\u5f8c\u306b<\/h1>\n\n\n\n<p>\u7279\u306b\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>docker\u3092\u4f7f\u7528\u3057\u3066\u30ed\u30fc\u30ab\u30eb\u306bLambda\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306f Node.js \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":5116,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-1685","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/1685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1685"}],"version-history":[{"count":8,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/1685\/revisions"}],"predecessor-version":[{"id":5118,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/1685\/revisions\/5118"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/5116"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}