{"id":7969,"date":"2016-12-27T15:52:30","date_gmt":"2016-12-27T15:52:30","guid":{"rendered":"https:\/\/dev.fukata.org\/?p=7969"},"modified":"2017-08-11T23:14:50","modified_gmt":"2017-08-11T23:14:50","slug":"%e3%81%93%e3%81%ae%e3%82%b5%e3%82%a4%e3%83%88%e3%81%abdocker%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/7969\/","title":{"rendered":"\u3053\u306e\u30b5\u30a4\u30c8\u306bdocker\u3092\u4f7f\u3063\u3066\u307f\u305f"},"content":{"rendered":"
<\/a><\/p>\n \u524d\u56de\u3001h2o+php\u306edocker\u30a4\u30e1\u30fc\u30b8\u3092\u7df4\u7fd2\u304c\u3066\u3089\u306b\u4f5c\u3063\u3066\u307f\u305f\u306e\u3067\u4eca\u56de\u306f\u305d\u308c\u3092\u4f7f\u3063\u3066\u3053\u306e\u4e3b\u306bWordPress\u3067\u69cb\u6210\u3055\u308c\u305f\u30b5\u30a4\u30c8\u3092docker\u30b3\u30f3\u30c6\u30ca\u3092\u4f7f\u3063\u3066\u307f\u305f\u3002<\/p>\n <\/p>\n \u76ee\u6b21<\/p> \u524d\u56de\u3068\u307b\u3068\u3093\u3069\u69cb\u6210\u306f\u5909\u308f\u3063\u3066\u306a\u3044\u3002<\/p>\n \u4f7f\u3063\u305fdocker\u30a4\u30e1\u30fc\u30b8\u306f\u4e0b\u8a18\u3002<\/p>\n \/var\/www \u4ee5\u4e0b\u306b\u3042\u308bWordPress\u3084\u305d\u306e\u4ed6\u306eWEB\u306b\u516c\u958b\u3057\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u306f\u73fe\u72b6\u306f\u30b3\u30f3\u30c6\u5316\u51fa\u6765\u3066\u3044\u306a\u3044\u306e\u3067\u305d\u306e\u307e\u307e\u30db\u30b9\u30c8\u306b\u7f6e\u3044\u3066\u3044\u308b\u72b6\u614b\u3068\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n \u3053\u308c\u3082\u30b3\u30f3\u30c6\u30ca\u5316\u3057\u3088\u3046\u304b\u3068\u601d\u3063\u305f\u3093\u3060\u3051\u3069WordPress\u81ea\u8eab\u3067\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3068\u304b\u3082\u3042\u308b\u3057\u30ed\u30fc\u30ab\u30eb\u3067\u5909\u66f4\u3057\u3066\u30a4\u30e1\u30fc\u30b8\u5316\u3057\u3066\u518d\u30a2\u30c3\u30d7\u3063\u3066\u306e\u304c\u500b\u4eba\u3067\u904b\u55b6\u3059\u308b\u30d6\u30ed\u30b0\u7a0b\u5ea6\u3060\u3068\u9762\u5012\u304f\u3055\u3055\u304c\u52dd\u3061\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u826f\u3044\u6848\u304c\u601d\u3044\u6d6e\u304b\u3076\u307e\u3067\u3068\u308a\u3042\u3048\u305a\u30db\u30b9\u30c8\u5074\u306b\u7f6e\u304f\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n \u306a\u306e\u3067\u3001h2o-php\u30b3\u30f3\u30c6\u30ca\u3068\u306fvolume\u306b\u6307\u5b9a\u3057\u3066\u30de\u30a6\u30f3\u30c8\u3057\u3066\u3044\u308b\u3002<\/p>\n h2o-php\u30b3\u30f3\u30c6\u30ca\u304b\u3089mysql,redis\u30b3\u30f3\u30c6\u30ca\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306a\u8a2d\u5b9a\u3092\u884c\u3063\u3066\u3044\u308b\u3002<\/p>\n docker run\u306elink\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u4ed6\u30b3\u30f3\u30c6\u30ca\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u74b0\u5883\u5909\u6570\u306b\u8272\u3005\u5b9a\u7fa9\u3055\u308c\u308b\u306e\u3067\u305d\u308c\u3092\u4f7f\u3046\u3002<\/p>\n \u4eca\u56de\u3001\u521d\u3081\u3066php\u306e ?:<\/em> \u3068\u3044\u3046\u6f14\u7b97\u5b50\u3092\u77e5\u3063\u305f\u3002 ansible\u306e\u30bf\u30b9\u30af\u304b\u3089docker\u30b3\u30f3\u30c6\u30ca\u306e\u90e8\u5206\u3060\u3051\u629c\u7c8b\u3002<\/p>\n \u4eca\u56de\u3001DigitalOcean\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092512MB\u30d7\u30e9\u30f3\u306b\u5909\u66f4\u3057\u3066\u307f\u305f\u3093\u3060\u3051\u3069\u666e\u901a\u306b\u52d5\u3044\u3066\u308b\u3063\u307d\u3044\u3002\u304b\u306a\u308a\u30ae\u30ea\u30ae\u30ea\u306b\u306a\u3063\u3066\u308b\u306e\u3067\u4f55\u304b\u3042\u308b\u3068\u3059\u3050\u3044\u3063\u3071\u3044\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u305d\u3046\u306a\u4e0d\u5b89\u306f\u3042\u308b\u3051\u3069\u3002<\/p>\n \u3068\u308a\u3042\u3048\u305a\u3001\u4eca\u5e74\u4e2d\u306b\u3084\u308a\u305f\u304b\u3063\u305fdocker\u30b3\u30f3\u30c6\u30ca\u3092\u4f7f\u3063\u3066\u30b5\u30a4\u30c8\u3092\u516c\u958b\u51fa\u6765\u305f\u306e\u306f\u826f\u304b\u3063\u305f\u3002<\/p>\n \u305d\u308d\u305d\u308dEC2\u306b\u79fb\u884c\u3057\u3088\u3046\u304b\u306a\u3002\u3069\u3046\u305b\u306a\u3089terraform\u306a\u3069\u4f7f\u3063\u3066\u79fb\u884c\u3057\u305f\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u524d\u56de\u3001h2o+php\u306edocker\u30a4\u30e1\u30fc\u30b8\u3092\u7df4\u7fd2\u304c\u3066\u3089\u306b\u4f5c\u3063\u3066\u307f\u305f\u306e\u3067\u4eca\u56de\u306f\u305d\u308c\u3092\u4f7f\u3063\u3066\u3053\u306e\u4e3b\u306bWordPress\u3067\u69cb\u6210\u3055\u308c\u305f\u30b5\u30a4\u30c8\u3092docker\u30b3\u30f3\u30c6\u30ca\u3092\u4f7f\u3063\u3066\u307f\u305f\u3002 … \u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":9223372036854775807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1980],"tags":[1127,1125,1081,984,1072],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/7969"}],"collection":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/comments?post=7969"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/7969\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media\/9223372036854775807"}],"wp:attachment":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media?parent=7969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=7969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=7969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\u69cb\u6210<\/span><\/h2>\n
\n
docker\u30a4\u30e1\u30fc\u30b8<\/span><\/h2>\n
\n
wp-config.php<\/span><\/h2>\n
\n\/** MySQL hostname *\/\ndefine('DB_HOST', getenv('DB_PORT_3306_TCP_ADDR') ?: 'localhost');\n\n\/\/ redis\ndefine('WP_REDIS_HOST', getenv('REDIS_PORT_6379_TCP_ADDR') ?: 'localhost');\ndefine('WP_REDIS_PORT', getenv('REDIS_PORT_6379_TCP_PORT') ?: '6379');\n<\/pre>\n
\n\u3044\u308f\u3086\u308b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u5b9a\u7fa9\u3057\u3066\u3042\u3052\u308b\u6642\u306b\u4fbf\u5229\u306a\u3084\u3064\u3002<\/p>\nansible<\/span><\/h2>\n
\n- name: Create mysql container\n docker_container:\n name: db\n image: mysql:5.7\n pull: true\n restart: yes\n restart_policy: always\n env:\n MYSQL_ALLOW_EMPTY_PASSWORD: YES\n MYSQL_USER: \"{{ db_user }}\"\n MYSQL_PASSWORD: \"{{ db_password }}\"\n ports:\n - 127.0.0.1:3306:3306\n volumes:\n - \/var\/lib\/mysql:\/var\/lib\/mysql\n - \/etc\/mysql:\/etc\/mysql\n tags: mysql\n\n- name: Create redis container\n docker_container:\n name: redis\n image: redis:3.2\n pull: true\n restart: yes\n restart_policy: always\n ports:\n - 127.0.0.1:6379:6379\n volumes:\n - \/etc\/redis:\/etc\/redis\n tags: redis\n\n- name: Create h2o container\n docker_container:\n name: h2o\n image: fukata\/h2o-php\n pull: true\n restart: yes\n restart_policy: always\n ports:\n - 0.0.0.0:80:80\n - 0.0.0.0:443:443\n links:\n - db\n - redis\n volumes:\n - \/var\/www:\/var\/www\n - \/var\/log\/h2o:\/var\/log\/h2o\n - \/etc\/h2o:\/etc\/h2o\n - \/etc\/letsencrypt:\/etc\/letsencrypt\n tags: h2o\n\n<\/pre>\n
\u307e\u3068\u3081<\/span><\/h2>\n