{"id":591,"date":"2019-04-16T08:59:22","date_gmt":"2019-04-15T23:59:22","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=591"},"modified":"2026-01-30T19:09:20","modified_gmt":"2026-01-30T10:09:20","slug":"docker%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=591","title":{"rendered":"\u3010docker\u3011docker\u30d5\u30a1\u30a4\u30eb\u306b\u3064\u3044\u3066"},"content":{"rendered":"\n<p>docker\u30d5\u30a1\u30a4\u30eb\u306f\u30d9\u30fc\u30b9\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u5143\u306bdocker\u30a4\u30e1\u30fc\u30b8\u3092\u751f\u6210\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u4f8b\u3048\u3070CentOs\u306e\u30a4\u30e1\u30fc\u30b8\u306bphp\u3001apache\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u6642\u306bapache\u3092\u8d77\u52d5\u72b6\u614b\u306b\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<br>\u4eca\u56de\u306f\u3001docker\u30d5\u30a1\u30a4\u30eb\u3067\u6307\u5b9a\u3059\u308b\u57fa\u672c\u7684\u306a\u30b3\u30de\u30f3\u30c9\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<br>\u306a\u304a\u3001\u4ee5\u4e0b\u304c\u7406\u89e3\u51fa\u6765\u305f\u5f8c\u306b\u3001\u5f53\u9805\u3092\u8aad\u3080\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">\u5408\u308f\u305b\u3066\u8aad\u3082\u3046<\/span>\n<p><a href=\"https:\/\/dennie.tokyo\/it\/?p=455\" rel=\"noopener noreferrer\" target=\"_blank\">docker \u3092\u4f7f\u7528\u3057\u305fLAMP\u958b\u767a\u74b0\u5883\u306e\u69cb\u7bc9<\/a><\/p>\n<\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u30a4\u30e1\u30fc\u30b8\u4f5c\u6210<\/h1>\n\n\n\n<p>docker\u30d5\u30a1\u30a4\u30eb\u304b\u3089docker\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br>docker\u30a4\u30e1\u30fc\u30b8\u306e\u4f5c\u6210\u306b\u306f <strong>build\u30b3\u30de\u30f3\u30c9<\/strong> \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<br><strong>dockerfile<\/strong> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u4efb\u610f\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3001<strong>dockerfile<\/strong> \u304c\u5b58\u5728\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30d1\u30b9\u3092\u6307\u5b9a\u3057 <strong>build\u30b3\u30de\u30f3\u30c9<\/strong> \u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<br>build\u3059\u308b\u969b\u306bdocker\u30a4\u30e1\u30fc\u30b8\u306b\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002&#8221;\u30a4\u30e1\u30fc\u30b8\u540d:\u30bf\u30b0\u540d&#8221;\u306e\u5f62\u5f0f\u3067\u3059\u3002<br>\u4ee5\u4e0b\u306f\u3001\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b <strong>dockerfile<\/strong> \u304c\u5b58\u5728\u3057\u3001docker\u30a4\u30e1\u30fc\u30b8\u306e\u540d\u524d\u3092&#8221;php7.1&#8243;\u3068\u3057\u30bf\u30b0\u540d\u3092&#8221;1&#8243;\u3068\u3057\u3066\u3001 <strong>build\u30b3\u30de\u30f3\u30c9<\/strong> \u3092\u5b9f\u884c\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>docker build -t php71:1 .<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">dockerfile\u306e\u4f8b<\/h1>\n\n\n\n<p>\u4ee5\u4e0b\u306fdockerfile\u306e\u4f8b\u306b\u306a\u308a\u307e\u3059\u3002<br>\u306a\u304a\u3001\u3053\u306edocekr\u30d5\u30a1\u30a4\u30eb\u306f\u30d3\u30eb\u30c9\u306b\u5931\u6557\u3059\u308b\u306e\u3067\u4f7f\u7528\u3057\u306a\u3044\u3067\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># \u30a4\u30e1\u30fc\u30b8\u3092\u6307\u5b9a\u3059\u308b\u3002\nFROM amazonlinux\n\n# \u30d3\u30eb\u30c9\u6642\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c(wget\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002)\nRUN yum install -y wget\n\n# \u30b3\u30f3\u30c6\u30ca\u3078\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u3059\u308b\u3002\nADD .\/composer-install.sh \/home\/tmp\/composer-install.sh\n\n# \u30b3\u30f3\u30c6\u30ca\u3078\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc\u3059\u308b\u3002\nCOPY .\/composer-install.sh \/home\/tmp\/composer-install.sh\n\n#\u30dd\u30fc\u30c880\u3092\u958b\u3051\u308b\u3002\nEXPOSE 80\n\n#\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3057\u305f\u6642\u306bapache\u8d77\u52d5\u3059\u308b\u3002\nCMD [&quot;\/usr\/sbin\/httpd&quot;, &quot;-D&quot;, &quot;FOREGROUND&quot;]<\/code><\/pre><\/div>\n\n\n\n<p>\u4ee5\u964d\u306f\u3001docker\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u306b\u3064\u3044\u3066\u306e\u8aac\u660e\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8<\/h2>\n\n\n\n<p>\u4f7f\u7528\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br>&#8220;\u30a4\u30e1\u30fc\u30b8\u540d:\u30bf\u30b0\u540d&#8221;\u3067\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<br>\u30bf\u30b0\u540d\u306f\u7701\u7565\u53ef\u80fd\u3067\u3059\u3002<br>\u4ee5\u4e0b\u306e\u4f8b\u306f <a rel=\"noopener noreferrer\" href=\"https:\/\/hub.docker.com\/\" target=\"_blank\">docker hub<\/a> \u3067\u516c\u958b\u3055\u308c\u3066\u3044\u308bamazonLinux\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>FROM amazonlinux<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d3\u30eb\u30c9\u6642\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c<\/h2>\n\n\n\n<p><strong>RUN\u30b3\u30de\u30f3\u30c9<\/strong> \u306f\u3001<strong>build\u30b3\u30de\u30f3\u30c9<\/strong> \u3092\u5b9f\u884c\u3059\u308b\u969b\u306b\u3001\u5b9f\u884c\u3055\u308c\u308b\u30b3\u30de\u30f3\u30c9\u3092\u6307\u5b9a\u51fa\u6765\u307e\u3059\u3002<br><strong>RUN\u30b3\u30de\u30f3\u30c9<\/strong> \u306f\u8907\u6570\u56de\u4f7f\u7528\u51fa\u6765\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306f yum\u3092\u4f7f\u7528\u3057\u3066wget\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>RUN yum install -y wget<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u306e\u8ffd\u52a0<\/h2>\n\n\n\n<p><strong>ADD\u30b3\u30de\u30f3\u30c9<\/strong> \u3067\u30db\u30b9\u30c8OS\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30f3\u30c6\u30ca\u306b\u8ffd\u52a0\u51fa\u6765\u307e\u3059\u3002<br><strong>ADD\u30b3\u30de\u30f3\u30c9<\/strong> \u306e\u5834\u5408\u3001\u5727\u7e2e\u30d5\u30a1\u30a4\u30eb\u306f\u81ea\u52d5\u7684\u306b\u89e3\u51cd\u3055\u308c\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306f\u3001\u30db\u30b9\u30c8OS\u306b\u5b58\u5728\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30b2\u30b9\u30c8OS\u3078\u8ffd\u52a0\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>ADD .\/composer-install.sh \/home\/tmp\/composer-install.sh<\/code><\/pre><\/div>\n\n\n\n<p>\u306a\u304a\u3001\u5916\u90e8\u306e\u30d5\u30a1\u30a4\u30eb\u3082\u30b3\u30f3\u30c6\u30ca\u306b\u8ffd\u52a0\u51fa\u6765\u307e\u3059\u3002<br>\u4f8b\u3048\u3070Git\u30b3\u30de\u30f3\u30c9\u3067\u5916\u90e8\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u3044\u5834\u5408\u3001<strong>ADD\u30b3\u30de\u30f3\u30c9<\/strong> \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30d4\u30fc<\/h2>\n\n\n\n<p><strong>COPY\u30b3\u30de\u30f3\u30c9<\/strong> \u306f\u3001\u30db\u30b9\u30c8OS\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002<br>\u81ea\u52d5\u7684\u306b\u89e3\u51cd\u3092\u884c\u3044\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>COPY .\/composer-install.sh \/home\/tmp\/composer-install.sh<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30dd\u30fc\u30c8\u306e\u958b\u653e<\/h2>\n\n\n\n<p>\u30dd\u30fc\u30c8\u3092\u958b\u653e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>EXPOSE 80<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u6642\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c<\/h2>\n\n\n\n<p><strong>CMD\u30b3\u30de\u30f3\u30c9<\/strong> \u306f <strong>RUN\u30b3\u30de\u30f3\u30c9<\/strong> \u3068\u306f\u9055\u3044\u3001\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u6642\u306b\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<br><strong>RUN\u30b3\u30de\u30f3\u30c9<\/strong> \u3068\u9055\u3044\u30011\u56de\u3057\u304b\u6307\u5b9a\u51fa\u6765\u307e\u305b\u3093\u3002<br>\u4ee5\u4e0b\u306f\u3001\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u6642\u306bweb\u30b5\u30fc\u30d0\u3092\u8d77\u52d5\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>CMD [&quot;\/usr\/sbin\/httpd&quot;, &quot;-D&quot;, &quot;FOREGROUND&quot;]<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u6700\u5f8c\u306b<\/h1>\n\n\n\n<p>\u4f7f\u7528\u53ef\u80fd\u306a\u30b3\u30de\u30f3\u30c9\u306f\u4ed6\u306b\u3082\u3042\u308a\u307e\u3059\u3002<br>\u6b21\u56de\u306fPHP\u958b\u767a\u74b0\u5883\u3092\u4f5c\u6210\u3059\u308b\u70ba\u306edocker\u30d5\u30a1\u30a4\u30eb\u306e\u8a18\u8ff0\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">\u6b21\u56de<\/span>\n<p><a href=\"https:\/\/dennie.tokyo\/it\/?p=1532\" rel=\"noopener noreferrer\" target=\"_blank\">\u3010docker\u3011docker\u30d5\u30a1\u30a4\u30eb\u306e\u8a18\u8ff0\u4f8b \u2013 PHP\u958b\u767a\u74b0\u5883<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>docker\u30d5\u30a1\u30a4\u30eb\u306f\u30d9\u30fc\u30b9\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u5143\u306bdocker\u30a4\u30e1\u30fc\u30b8\u3092\u751f\u6210\u3057\u3066\u304f\u308c\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-591","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\/591","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=591"}],"version-history":[{"count":35,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/591\/revisions"}],"predecessor-version":[{"id":3262,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/591\/revisions\/3262"}],"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=591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}