{"id":4319,"date":"2014-08-18T09:50:48","date_gmt":"2014-08-18T00:50:48","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=4319"},"modified":"2018-11-14T16:33:51","modified_gmt":"2018-11-14T07:33:51","slug":"rails-development-on-docker","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2014\/08\/18\/rails-development-on-docker\/","title":{"rendered":"Docker\u4e0a\u3067Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u9234\u6728\u3067\u3059\u3002<\/p>\n<p>\u524d\u56de\u3001\u524d\u3005\u56de\u306f Docker \u306e\u57fa\u672c\u3092\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306f Rails \u306e\u958b\u767a\u74b0\u5883\u3092 Docker \u4e0a\u306b\u4f5c\u308a\u4e0a\u3052\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u5168\u4f53\u7684\u306a\u69cb\u6210<\/h2>\n<p>\u5168\u4f53\u7684\u306a\u69cb\u6210\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u540d\u306f hello \u3068\u3059\u308b\u3002<\/li>\n<li>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u306f PostgreSQL \u3092\u4f7f\u7528\u3059\u308b\u3002<\/li>\n<li>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3068\u958b\u767a\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u6210\u3059\u308b\u3002<\/li>\n<li>\u958b\u767a\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u306b\u306f SSH \u3067\u63a5\u7d9a\u3059\u308b\u3002<\/li>\n<\/ul>\n<h2>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u307e\u305a\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>Docker Hub \u3067 PostgreSQL \u306e\u30a4\u30e1\u30fc\u30b8\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true\"># \u30a4\u30e1\u30fc\u30b8\u3092\u53d6\u5f97\u3059\u308b.\r\ndocker pull postgres:9.3.5\r\n\r\n# \u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3059\u308b.\r\ndocker run -d --name postgres -e LC_ALL=C.UTF-8 postgres:9.3.5<\/pre>\n<p>\u30a4\u30e1\u30fc\u30b8\u3092\u53d6\u5f97\u3057\u3066\u8d77\u52d5\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u30b3\u30f3\u30c6\u30ca\u306f\u30c7\u30bf\u30c3\u30c1\u30e2\u30fc\u30c9\u3067\u52d5\u304b\u3057\u305f\u3044\u306e\u3067 -d \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001\u30b3\u30f3\u30c6\u30ca\u306b\u306f\u540d\u524d\u3092\u4ed8\u3051\u3066\u304a\u304f\u3068\u4fbf\u5229\u306a\u306e\u3067 --name \u3067\u300cpostgres\u300d\u3068\u3044\u3046\u540d\u524d\u3092\u4ed8\u3051\u307e\u3057\u305f\u3002<\/p>\n<p>\u30dd\u30a4\u30f3\u30c8\u306f\u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u300c-e LC_ALL=C.UTF-8\u300d\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u3068\u3053\u308d\u3067\u3059\u3002\u3053\u308c\u306f initdb \u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30af\u30e9\u30b9\u30bf\u3092\u521d\u671f\u5316\u3059\u308b\u3068\u304d\u306e\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092 UTF-8 \u3068\u3059\u308b\u305f\u3081\u3067\u3059\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f SQL_ASCII \u306b\u306a\u308a\u307e\u3059\uff09\u3002<\/p>\n<h2>Rails \u958b\u767a\u7528\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u6b21\u306b Rails \u958b\u767a\u7528\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>PostgreSQL \u306f\u65e2\u5b58\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u305d\u306e\u307e\u307e\u4f7f\u7528\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u5ea6\u306f\u500b\u4eba\u7528\u306e\u958b\u767a\u74b0\u5883\u3092\u4f5c\u308a\u305f\u3044\u306e\u3067\u305d\u3046\u3082\u3044\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>Dockerfile \u3092\u66f8\u3044\u3066\u81ea\u5206\u7528\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true\">FROM ubuntu:14.04\r\nMAINTAINER TECHSCORE\r\n\r\n# (1) \u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u66f4\u65b0\u3059\u308b.\r\nRUN apt-get update\r\n\r\n# (2) \u4e00\u822c\u7684\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b.\r\nRUN apt-get install -y aptitude\r\nRUN apt-get install -y git\r\nRUN apt-get install -y subversion\r\nRUN apt-get install -y tree\r\n# ... \u4ed6\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u305f\u3044\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u3042\u308c\u3070\u8ffd\u52a0\u3059\u308b.\r\n\r\n# (3) SSH \u30b5\u30fc\u30d0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b.\r\nRUN apt-get install -y openssh-server\r\nRUN mkdir \/var\/run\/sshd\r\nRUN ssh-keygen -A\r\nRUN sed -ie 's\/^\\(session \\+required \\+pam_loginuid.so\\)\/#\\1\/' \/etc\/pam.d\/sshd\r\n\r\n# (4) RVM \u306b\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b.\r\nRUN apt-get install -y curl\r\n\r\n# (5) Rails \u306b\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b.\r\nRUN apt-get install -y postgresql-client-9.3\r\nRUN apt-get install -y postgresql-server-dev-9.3\r\nRUN apt-get install -y ruby-execjs\r\n\r\n# (6) \u958b\u767a\u7528\u306e\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3059\u308b.\r\nRUN useradd -m -s \/bin\/bash rails\r\nRUN echo 'rails:password' | chpasswd\r\nRUN echo 'rails ALL=(ALL) NOPASSWD:ALL' &gt; \/etc\/sudoers.d\/rails\r\n\r\n# (7) rails \u30e6\u30fc\u30b6\u306b\u5207\u308a\u66ff\u3048\u308b.\r\nUSER rails\r\nENV HOME \/home\/rails\r\n\r\n# (8) RVM \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b.\r\nRUN curl -sSL https:\/\/get.rvm.io | bash -s stable\r\nRUN bash -l -c 'rvm requirements'\r\n\r\n# (9) Ruby \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b.\r\nRUN bash -l -c 'rvm get stable'\r\nRUN bash -l -c 'rvm install ruby-2.1.2'\r\nRUN bash -l -c 'rvm use --default ruby-2.1.2'\r\n\r\n# (10) dotfiles (.gemrc).\r\nRUN echo 'gem: --no-ri --no-rdoc' &gt; ~\/.gemrc\r\n\r\n# (11) Rails \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b.\r\nRUN bash -l -c 'gem install rails -v 4.1.4'\r\n\r\n# (12) \u4f5c\u696d\u7528\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3059\u308b (\u3053\u306e\u4e2d\u306b Rails \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b).\r\nRUN mkdir ~\/workspace\r\n\r\n# (13) root \u30e6\u30fc\u30b6\u306b\u5207\u308a\u66ff\u3048\u308b.\r\nUSER root\r\n\r\n# (14) \u30b3\u30f3\u30c6\u30ca\u5916\u306b\u51fa\u3059\u30dd\u30fc\u30c8\u3092\u6307\u5b9a\u3059\u308b.\r\nEXPOSE 22 3000\r\n\r\n# (15) \u5916\u90e8\u304b\u3089\u30de\u30a6\u30f3\u30c8\u3059\u308b\u5834\u6240\u3092\u6307\u5b9a\u3059\u308b.\r\nVOLUME \/home\/rails\/workspace\r\n\r\n# (16) \u8d77\u52d5\u6642\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6307\u5b9a\u3059\u308b.\r\nCMD [\"\/usr\/sbin\/sshd\", \"-D\"]\r\n<\/pre>\n<p>\u307e\u3068\u307e\u308a\u3054\u3068\u306b\u30b3\u30e1\u30f3\u30c8\u3092\u8a18\u8f09\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u9806\u756a\u306b\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>(1) \u306e apt-get update \u3067\u306f\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u66f4\u65b0\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u3088\u3046\u306a\u4e00\u822c\u7684\u306a\u51e6\u7406\u306f Dockerfile \u306e\u5148\u982d\u306e\u307b\u3046\u306b\u8a18\u8ff0\u3057\u3066\u304a\u304f\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002\u305d\u3046\u3059\u308b\u3053\u3068\u3067\u3001\u8a66\u884c\u932f\u8aa4\u3057\u306a\u304c\u3089 Dockerfile \u3092\u4fee\u6b63\uff06\u30d3\u30eb\u30c9\u3092\u7e70\u308a\u8fd4\u3059\u3068\u304d\u306e\u4f5c\u696d\u6642\u9593\u3092\u77ed\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3068\u3044\u3046\u3082\u306e\u3001Dockerfile \u3092\u30d3\u30eb\u30c9\u3059\u308b\u6642\u306f 1 \u884c 1 \u884c\u304c\u9806\u756a\u306b\u5b9f\u884c\u3055\u308c\u3001\u4e2d\u9593\u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u30b3\u30df\u30c3\u30c8\u3055\u308c\u307e\u3059\u3002\u4e2d\u9593\u30a4\u30e1\u30fc\u30b8\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u3055\u308c\u308b\u305f\u3081\u3001Dockerfile \u306e\u6700\u5f8c\u306e\u307b\u3046\u3092\u4fee\u6b63\u3057\u3066\u30d3\u30eb\u30c9\u3057\u306a\u304a\u3057\u305f\u5834\u5408\u3001\u65e2\u306b\u3042\u308b\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u6d41\u7528\u3055\u308c\u3001\u5909\u66f4\u3057\u305f\u90e8\u5206\u79fb\u884c\u304c\u65b0\u305f\u306b\u30d3\u30eb\u30c9\u3055\u308c\u308b\u305f\u3081\u3067\u3059\u3002\u53cd\u5bfe\u306b Dockerfile \u306e\u5148\u982d\u306e\u65b9\u3092\u5909\u66f4\u3059\u308b\u3068\u3001\u307b\u3068\u3093\u3069\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u6d41\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u30d3\u30eb\u30c9\u6642\u9593\u306f\u3042\u307e\u308a\u77ed\u7e2e\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>(2) \u3067\u306f\u4e00\u822c\u7684\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u307e\u3059\u3002\u4ed6\u306b\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u3042\u308c\u3070\u3001\u3053\u3053\u306b\u8ffd\u52a0\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>(3) \u3067\u306f SSH \u30b5\u30fc\u30d0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u5fc5\u8981\u306a\u8a2d\u5b9a\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>(4), (5) \u306f\u305d\u308c\u305e\u308c RVM (Ruby Version Manager) \u3068 Ruby \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306b\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>(6) \u3067\u306f\u958b\u767a\u7528\u306e\u30e6\u30fc\u30b6\u3068\u3057\u3066 rails \u3068\u3044\u3046\u540d\u524d\u306e\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u300cpassword\u300d\u3068\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u9069\u5b9c\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u307e\u305f\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u7121\u3057\u3067 sudo \u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u958b\u767a\u7528\u306e\u74b0\u5883\u3060\u304b\u3089\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u306e\u554f\u984c\u306f\u7121\u3044\u3068\u3044\u3046\u524d\u63d0\u3067\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>(7) \u3067\u306f rails \u306b\u30e6\u30fc\u30b6\u3092\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002(8), (9) \u3067 RVM \u3068 Ruby-2.1.2 \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3001(10) \u3067 gem \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u304d\u306b\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u751f\u6210\u3057\u306a\u3044\u305f\u3081\u306e\u8a2d\u5b9a\u3092\u884c\u3044\uff08\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3044\u3068\u3044\u3046\u65b9\u306f\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u304f\u3060\u3055\u3044\uff09\u3001\u305d\u3057\u3066 (11) \u3067 Rails-4.1.4 \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>(12) \u3067\u306f\u4f5c\u696d\u7528\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u3057\u3066 ~\/workspace \u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\u5f8c\u307b\u3069 hello \u3068\u3044\u3046\u540d\u524d\u306e Rails \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092 ~\/workspace\/hello \u306b\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>(13) \u3067\u306f root \u30e6\u30fc\u30b6\u306b\u623b\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u306f SSH \u30b5\u30fc\u30d0\u3092 root \u6a29\u9650\u3067\u52d5\u304b\u3059\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>(14) \u3067\u306f\u30b3\u30f3\u30c6\u30ca\u5916\u306b\u51fa\u3059\u30dd\u30fc\u30c8\u3068\u3057\u3066 22 (SSH) \u3068 3000 (Rails) \u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>(15) \u3067\u306f\u5916\u90e8\u304b\u3089\u30de\u30a6\u30f3\u30c8\u3059\u308b\u5834\u6240\u3068\u3057\u3066 \/home\/rails\/workspace \u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u30b3\u30f3\u30c6\u30ca\u5185\u3067\u958b\u767a\u3057\u305f\u30b3\u30fc\u30c9\u306f git \u3084 subversion \u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30c1\u30a7\u30c3\u30af\u30a4\u30f3\u3059\u308b\u306e\u3067\u5916\u90e8\u3068\u30d5\u30a1\u30a4\u30eb\u3092\u5171\u6709\u3059\u308b\u5fc5\u8981\u304c\u7121\u3044\u3068\u3044\u3046\u5834\u5408\u306f\u4e0d\u8981\u3067\u3059\u304c\u3001\u30b3\u30f3\u30c6\u30ca\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30f3\u30c6\u30ca\u5916\u304b\u3089\u7c21\u5358\u306b\u53d6\u308a\u51fa\u305b\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304d\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>(16) \u3067\u306f\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3057\u305f\u3068\u304d\u306b\u5b9f\u884c\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u4eca\u56de\u306f\u30b3\u30f3\u30c6\u30ca\u306b\u306f ssh \u63a5\u7d9a\u3059\u308b\u306e\u3067\u3001ssh \u306e\u30c7\u30fc\u30e2\u30f3\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Dockerfile \u3092\u4f5c\u6210\u3057\u305f\u3089\u3001\u30d3\u30eb\u30c9\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">cd &lt;Dockefile \u3092\u4f5c\u6210\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea&gt;\r\ndocker build -t work:0.0.0 .<\/pre>\n<p>\u30d3\u30eb\u30c9\u306b\u306f\u3057\u3070\u3089\u304f\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u304c\u3001\u5b8c\u4e86\u3059\u308b\u3068 work:0.0.0 \u3068\u3044\u3046\u30a4\u30e1\u30fc\u30b8\u304c\u51fa\u6765\u4e0a\u304c\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">$ docker images\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE\r\nwork                0.0.0               bfd16ab196b3        About an hour ago   661.4 MB\r\n...<\/pre>\n<h2>Rails \u958b\u767a\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3059\u308b<\/h2>\n<p>\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3059\u308b\u524d\u306b\u3001\u30b3\u30f3\u30c6\u30ca\u5185\u306b\u30de\u30a6\u30f3\u30c8\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true\">mkdir ~\/workspace\r\nchmod 777 ~\/workspace<\/pre>\n<p>\u6b21\u306b\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">docker run -d --name work --publish 80:3000 --publish 10022:22 --link postgres:db \\\r\n  --volume ~\/workspace:\/home\/rails\/workspace --privileged work:0.0.0<\/pre>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u591a\u3044\u306e\u3067\u4e00\u3064\u305a\u3064\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>-d \u306f\u30b3\u30f3\u30c6\u30ca\u3092\u30c7\u30bf\u30c3\u30c1\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u3059\u3002\u30b3\u30f3\u30c6\u30ca\u3067\u52d5\u304b\u3059\u306e\u306f ssh \u306e\u30c7\u30fc\u30e2\u30f3\u306a\u306e\u3067\u30c7\u30bf\u30c3\u30c1\u30e2\u30fc\u30c9\u3092\u9078\u3073\u307e\u3057\u305f\u3002bash \u7b49\u306e\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306b\u64cd\u4f5c\u3059\u308b\u30d7\u30ed\u30bb\u30b9\u3092\u8d77\u52d5\u3059\u308b\u5834\u5408\u306f\u30a2\u30bf\u30c3\u30c1\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>--name work \u306f\u30b3\u30f3\u30c6\u30ca\u306b work \u3068\u3044\u3046\u540d\u524d\u3092\u4ed8\u3051\u307e\u3059\u3002\u540d\u524d\u3092\u4ed8\u3051\u3066\u304a\u304f\u3053\u3068\u3067\u3001\u30b3\u30f3\u30c6\u30ca\u306e\u505c\u6b62\/\u518d\u958b\u3092 docker stop work \u3084 docker start work \u306e\u3088\u3046\u306b\u540d\u524d\u3067\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u306e\u3067\u4fbf\u5229\u3067\u3059\u3002\u4f7f\u3044\u6368\u3066\u3067\u306f\u306a\u3044\u30b3\u30f3\u30c6\u30ca\uff08\u3057\u3070\u3089\u304f\u52d5\u304d\u7d9a\u3051\u308b\u30b3\u30f3\u30c6\u30ca\uff09\u306b\u306f --name \u3067\u540d\u524d\u3092\u4ed8\u3051\u3066\u304a\u304f\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>--publish 80:3000 \u306f\u30db\u30b9\u30c8\u306e 80 \u30dd\u30fc\u30c8\u3068\u30b3\u30f3\u30c6\u30ca\u5185\u306e 3000 \u30dd\u30fc\u30c8\u3092\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u307e\u3059\u3002\u3053\u308c\u3067 rails server \u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8d77\u52d5\u3059\u308c\u3070\u30db\u30b9\u30c8\u5074\u306e 80 \u30dd\u30fc\u30c8\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff083000 \u30dd\u30fc\u30c8\u306f rails server \u3067\u8d77\u52d5\u3057\u305f\u3068\u304d\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30dd\u30fc\u30c8\u3067\u3059\uff09\u3002--publish 10022:22 \u306f\u30db\u30b9\u30c8\u5074\u306e 10022 \u30dd\u30fc\u30c8\u3068\u30b3\u30f3\u30c6\u30ca\u5185\u306e 22 \u30dd\u30fc\u30c8\u3092\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u307e\u3059\u300222 \u30dd\u30fc\u30c8\u306f ssh \u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30dd\u30fc\u30c8\u3067\u3059\u304c\u3001\u30db\u30b9\u30c8\u5074\u306e 22 \u30dd\u30fc\u30c8\u3092\u4f7f\u7528\u3059\u308b\u3068\u56f0\u308b\uff08\u30db\u30b9\u30c8\u81ea\u8eab\u306b\u5916\u90e8\u304b\u3089 ssh \u63a5\u7d9a\u3057\u3066\u3044\u308b\uff09\u5834\u5408\u3082\u3042\u308b\u306e\u3067\u300110022 \u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>--link postgres:db \u306f\u6700\u521d\u306e\u65b9\u3067\u8d77\u52d5\u3057\u305f PostgreSQL \u304c\u52d5\u304f\u30b3\u30f3\u30c6\u30ca\u3068\u30ea\u30f3\u30af\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002\u3053\u308c\u306f postgres \u3068\u3044\u3046\u540d\u524d\u306e\u30b3\u30f3\u30c6\u30ca\u3092 db \u3068\u3044\u3046\u540d\u524d\u3067\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u3059\uff08\u8d77\u52d5\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u5185\u306e \/etc\/hosts \u306b\u30a8\u30f3\u30c8\u30ea\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\uff09\u3002<\/p>\n<p>--volume ~\/workspace:\/home\/rails\/workspace \u306f\u30db\u30b9\u30c8\u5074\u306e ~\/workspace \u3068\u30b3\u30f3\u30c6\u30ca\u5185\u306e \/home\/rails\/workspace \u3092\u30de\u30a6\u30f3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>--privileged \u306f --volume \u3068\u95a2\u9023\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u30b3\u30f3\u30c6\u30ca\u5185\u3067\u30de\u30a6\u30f3\u30c8\u9818\u57df\u306b\u5bfe\u3059\u308b\u6a5f\u80fd\u306f\u5236\u9650\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u306a\u3069\u3092\u884c\u304a\u3046\u3068\u3059\u308b\u3068\u300cPermission Denied\u300d\u3068\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002--privileged \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u30db\u30b9\u30c8\u5074\u3068\u540c\u3058\u6a29\u9650\u3092\u4e0e\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306e work:0.0.0 \u306f\u30b3\u30f3\u30c6\u30ca\u306e\u4f5c\u6210\u306b\u4f7f\u7528\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<h2>\u30b3\u30f3\u30c6\u30ca\u5185\u306b SSH \u63a5\u7d9a\u3059\u308b<\/h2>\n<p>\u30b3\u30f3\u30c6\u30ca\u5185\u306b SSH \u3067\u63a5\u7d9a\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:sh decode:true \">ssh -p 10022 rails@localhost<\/pre>\n<p>\u30b3\u30f3\u30c6\u30ca\u5185\u306e 22 \u30dd\u30fc\u30c8\u306f\u30db\u30b9\u30c8\u5074\u306e 10022 \u30dd\u30fc\u30c8\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u3053\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u63a5\u7d9a\u3059\u308b\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6c42\u3081\u3089\u308c\u307e\u3059\u304c\u3001Dockerfile \u5185\u3067\u8a2d\u5b9a\u3057\u305f\u300cpassword\u300d\u3068\u5165\u529b\u3059\u308c\u3070 OK \u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u30b3\u30f3\u30c6\u30ca\u5185\u3067\u4f5c\u696d\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>\u30b3\u30f3\u30c6\u30ca\u5185\u3092\u63a2\u7d22\u3059\u308b<\/h2>\n<p>\u30b3\u30f3\u30c6\u30ca\u5185\u3092\u63a2\u7d22\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\/etc\/hosts \u306e\u4e2d\u3092\u898b\u308b\u3068\u3001--link \u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u6307\u5b9a\u3057\u305f\u3068\u304a\u308a db \u3068\u3044\u3046\u30a8\u30f3\u30c8\u30ea\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">$ cat \/etc\/hosts\r\n...\r\n172.17.1.3      db\r\n<\/pre>\n<p>db \u30b5\u30fc\u30d0\u306b\u63a5\u7d9a\u3067\u304d\u308b\u304b\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:sh decode:true \">psql -h db -U postgres<\/pre>\n<p>\u63a5\u7d9a\u3067\u304d\u308c\u3070 OK \u3067\u3059\u3002<\/p>\n<h2>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>Rails \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3059\u308b\u524d\u306b\u3001\u63a5\u7d9a\u7528\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">createuser -h db -U postgres --createdb rails<\/pre>\n<p>rails \u3068\u3044\u3046\u540d\u524d\u3067\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<h2>Rails \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>hello \u3068\u3044\u3046\u540d\u524d\u306e Rails \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:sh decode:true \">cd ~\/workspace\r\nrails new -d postgresql hello<\/pre>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u305f\u3089\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u5148\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">cd ~\/workspace\/hello\r\nvi config\/database.yml<\/pre>\n<p>database.yml \u3092\u958b\u304d\u3001\u300chost: db\u300d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:yaml decode:true\">default: &amp;default\r\n  adapter: postgresql\r\n  encoding: unicode\r\n  # For details on connection pooling, see rails configuration guide\r\n  # http:\/\/guides.rubyonrails.org\/configuring.html#database-pooling\r\n  pool: 5\r\n  host: db # \u203b\u8ffd\u52a0\u203b\r\n...<\/pre>\n<p>\u6b21\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">rake db:create db:migrate<\/pre>\n<h2>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8d77\u52d5\u3059\u308b<\/h2>\n<p>\u9577\u3044\u9053\u306e\u308a\u3067\u3057\u305f\u304c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8d77\u52d5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:sh decode:true \">bin\/rails server<\/pre>\n<p>\u7121\u4e8b\u306b\u8d77\u52d5\u3067\u304d\u308c\u3070\u3001\u30db\u30b9\u30c8\u5074\u306e\u300chttp:\/\/localhost\/\u300d\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<h2>\u601d\u3063\u305f\u3053\u3068\u3001\u8003\u3048\u305f\u3053\u3068\u3001\u8a66\u884c\u932f\u8aa4\u3057\u305f\u3053\u3068<\/h2>\n<p>\u3053\u3053\u307e\u3067\u3084\u308b\u306e\u306b\u8272\u3005\u3068\u8a66\u884c\u932f\u8aa4\u3057\u305f\u306e\u3067\u3001\u305d\u306e\u9053\u306e\u308a\u3092\u7c21\u5358\u306b\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n<h3>Dockerfile \u3092\u4f5c\u308a\u4e0a\u3052\u308b\u306e\u306f\u5927\u5909\u3060<\/h3>\n<p>Dockerfile \u3092\u4f5c\u308b\u6642\u306f\u8a66\u884c\u932f\u8aa4\u306e\u9023\u7d9a\u3067\u3057\u305f\u3002\u5c11\u3057\u66f8\u3044\u3066\u306f\u30d3\u30eb\u30c9\u3057\u3066\u3001\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3089\u4fee\u6b63\u3057\u3066\u30fb\u30fb\u306e\u7e70\u308a\u8fd4\u3057\u306b\u306a\u308b\u306e\u3067\u3001\u3082\u306e\u3059\u3054\u304f\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3057\u305f\u3002\u7279\u306b\u300c\u3053\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3082\u5fc5\u8981\u3060\u3063\u305f\uff01 \u2192 Dockerfile \u306e\u59cb\u3081\u306e\u307b\u3046\u306b\u8ffd\u52a0 \u2192 \u307b\u3068\u3093\u3069\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u52b9\u304b\u306a\u3044\u306e\u3067\u30d3\u30eb\u30c9\u6642\u9593\u304c\u3059\u3054\u304f\u304b\u304b\u308b\u30fb\u30fb\u300d\u3068\u3044\u3046\u3053\u3068\u3082\u591a\u3005\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u300c\u3059\u3054\u304f\u6642\u9593\u304c\u304b\u304b\u308b\u30fb\u30fb\u300d\u3068\u6c17\u4ed8\u3044\u3066\u304b\u3089\u3001\u30d9\u30fc\u30b9\u3068\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3067 bash \u3092\u8d77\u52d5\u3057\u3001\u305d\u3053\u3067\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3061\u306a\u304c\u3089 Dockerfile \u306b\u8ee2\u8a18\u3057\u3066\u3044\u304f\u3084\u308a\u65b9\u306b\u5909\u66f4\u3057\u307e\u3057\u305f\u3002\u3042\u308b\u7a0b\u5ea6\u66f8\u304d\u4e0a\u3052\u3066\u304b\u3089\u4e00\u6c17\u306b\u30d3\u30eb\u30c9\u3059\u308c\u3070\u30c8\u30fc\u30bf\u30eb\u306e\u6642\u9593\u306f\u77ed\u304f\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h3>\u958b\u767a\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3067 bash \u3092\u52d5\u304b\u3059\u3079\u304d\u304b sshd \u3092\u52d5\u304b\u3059\u3079\u304d\u304b\uff08sshd \u306b\u3057\u305f\uff09<\/h3>\n<p>\u958b\u767a\u7528\u306e\u30b3\u30f3\u30c6\u30ca\uff08\u4eca\u56de\u306e\u4f8b\u3067\u306f work\uff09\u3067 bash \u3092\u52d5\u304b\u3059\u3079\u304d\u304b\u3001sshd \u3092\u8d77\u52d5\u3057\u3066 ssh \u63a5\u7d9a\u3059\u308b\u304b\u8ff7\u3044\u307e\u3057\u305f\u3002\u6700\u521d\u306f bash \u3092\u52d5\u304b\u3059\u3088\u3046\u306b\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001Ctrl+p \u3067\u4e00\u3064\u524d\u306e\u30b3\u30de\u30f3\u30c9\u3092\u51fa\u305b\u306a\u3044\uff08\u30c7\u30bf\u30c3\u30c1\u3059\u308b\u305f\u3081\u306e Ctrl+p Ctrl+q \u3068\u304b\u3076\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u4e00\u3064\u524d\u306e\u30b3\u30de\u30f3\u30c9\u3092\u51fa\u3059\u306b\u306f Ctrl+p Ctrl+p \u3068 2 \u56de\u5165\u529b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\uff09\u305f\u3081\u3001\u6700\u7d42\u7684\u306b ssh \u63a5\u7d9a\u3059\u308b\u3084\u308a\u65b9\u3092\u63a1\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n<h3>\u958b\u767a\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3067\u306f --volume \u3067\u30de\u30a6\u30f3\u30c8\u3057\u305f\u5834\u6240\u306b Rails \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u305f<\/h3>\n<p>\u958b\u767a\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3067 Rails \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u304c\u3001\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u306f --volume \u3067\u5916\u90e8\u304b\u3089\u30de\u30a6\u30f3\u30c8\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7f6e\u304f\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\u305d\u3046\u3057\u305f\u3053\u3068\u3067\u30b3\u30f3\u30c6\u30ca\u3092\u6c17\u8efd\u306b\u7834\u68c4\u3057\u3066\u4f5c\u308a\u76f4\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u983b\u7e41\u306b\u4f5c\u308a\u76f4\u3059\u53ef\u80fd\u6027\u306e\u3042\u308b\u30b3\u30f3\u30c6\u30ca\u306b\u3064\u3044\u3066\u306f\u3001\u30c7\u30fc\u30bf\u3092\u5916\u51fa\u3057\u3057\u3066\u304a\u3044\u305f\u65b9\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<h3>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u53b3\u5bc6\u306b\u6307\u5b9a\u3059\u308b\u3079\u304d\u304b\uff08\u6307\u5b9a\u3057\u306a\u304b\u3063\u305f\uff09<\/h3>\n<p>Dockerfile \u5185\u3067\u300cRUN apt-get install -y openssh-server\u300d\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3057\u305f\u304c\u3001\u300cRUN apt-get install -y openssh-server=1:6.6p1-2ubuntu2\u300d\u306e\u3088\u3046\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u53b3\u5bc6\u306b\u6307\u5b9a\u3059\u308b\u3079\u304d\u304b\u8ff7\u3044\u307e\u3057\u305f\u3002\u306a\u305c\u8ff7\u3063\u305f\u306e\u304b\u3068\u3044\u3046\u3068\u3001\u540c\u3058 Dockerfile \u3067\u3082\u30d3\u30eb\u30c9\u3057\u305f\u6642\u671f\u306b\u3088\u3063\u3066\u51fa\u6765\u4e0a\u304c\u308b\u30a4\u30e1\u30fc\u30b8\u304c\u7570\u306a\u3063\u3066\u3057\u307e\u3046\u53ef\u80fd\u6027\u304c\u3042\u308b\u306e\u306f\u3069\u3046\u3088\u3068\u601d\u3063\u305f\u304b\u3089\u3067\u3059\u3002\u7d50\u5c40\u300c\u305d\u3053\u307e\u3067\u795e\u7d4c\u8cea\u306b\u306a\u3089\u306a\u304f\u3066\u3082\u826f\u3044\u300d\u3068\u601d\u3044\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u6307\u5b9a\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h3>PostgreSQL \u306e\u30c7\u30fc\u30bf\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092 --volume \u3067\u6307\u5b9a\u3059\u308b\u3079\u304d\u304b\uff08\u6307\u5b9a\u3057\u306a\u304b\u3063\u305f\uff09<\/h3>\n<p>PostgreSQL \u306e\u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b --volume \u3067\u30c7\u30fc\u30bf\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\u3059\u308b\u304b\u3069\u3046\u304b\u3067\u3059\u3002\u9593\u9055\u3063\u3066 PostgreSQL \u306e\u30b3\u30f3\u30c6\u30ca\u3092\u524a\u9664\u3057\u3066\u3057\u307e\u3063\u305f\u5834\u5408\u306b\u30c7\u30fc\u30bf\u304c\u5931\u308f\u308c\u308b\u30ea\u30b9\u30af\u3092\u8003\u3048\u305f\u306e\u3067\u3059\u304c\u3001\u6c17\u306b\u3057\u3059\u304e\uff08\u672c\u756a\u74b0\u5883\u3060\u3063\u305f\u3089\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b\u3060\u308d\u3046\u3057\u3001\u624b\u5143\u306e\u74b0\u5883\u306e\u3088\u3046\u306b\u5168\u90e8\u307e\u3068\u3081\u3066\u524a\u9664\u306e\u3088\u3046\u306a\u3053\u3068\u306f\u3057\u306a\u3044\u306f\u305a\uff09\u3068\u3044\u3046\u7d50\u8ad6\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h3>\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306f\u3042\u308a\u304c\u305f\u3044\u3051\u308c\u3069\u3001\u60c5\u5831\u304c\u5c11\u306a\u3044<\/h3>\n<p>\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306f\u975e\u5e38\u306b\u3042\u308a\u304c\u305f\u3044\u5b58\u5728\u306a\u306e\u3067\u3059\u304c\u3001\u307e\u3060\u60c5\u5831\u304c\u5c11\u306a\u3044\u3068\u611f\u3058\u307e\u3059\u3002\u8d77\u52d5\u65b9\u6cd5\u4ee5\u5916\u306f\u8aac\u660e\u304c\u7121\u3044\u5834\u5408\u3082\u3042\u308a\u307e\u3059\u3002\u4eca\u56de\u306f PostgreSQL \u306e\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3059\u3050\u306b\u306f initdb \u3059\u308b\u3068\u304d\u306e\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u5909\u66f4\u3059\u308b\u65b9\u6cd5\u304c\u5206\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u56f0\u3063\u305f\u6642\u306f <a href=\"https:\/\/github.com\/docker-library\">Docker library<\/a> \u306e\u4e2d\u3092\u898b\u308b\u3068\u89e3\u6c7a\u3059\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<h3>\u3044\u3063\u305f\u3093\u52d5\u3051\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3089\u697d\u3060\u3063\u305f<\/h3>\n<p>\u8a66\u884c\u932f\u8aa4\u3057\u3066\u3044\u308b\u6bb5\u968e\u3092\u904e\u304e\u3066\u3057\u307e\u3048\u3070\u3001\u30b3\u30f3\u30c6\u30ca\u3092\u6c17\u8efd\u306b\u4f5c\u6210\/\u7834\u68c4\u3067\u304d\u308b\u306e\u3067\u697d\u3060\u3068\u601d\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u6d88\u3048\u3066\u306f\u56f0\u308b\u30c7\u30fc\u30bf\u306f --volume \u3067\u30db\u30b9\u30c8\u5074\u304b\u3089\u30de\u30a6\u30f3\u30c8\u3057\u3001\u30b3\u30f3\u30c6\u30ca\u3092\u6368\u3066\u3084\u3059\u304f\u3057\u3066\u304a\u304f\u3053\u3068\u3082\u30dd\u30a4\u30f3\u30c8\u3060\u3068\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Enjoy Docker!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u9234\u6728\u3067\u3059\u3002<\/p>\n<p>\u524d\u56de\u3001\u524d\u3005\u56de\u306f Docker \u306e\u57fa\u672c\u3092\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306f Rails \u306e\u958b\u767a\u74b0\u5883\u3092 Docker \u4e0a\u306b\u4f5c\u308a\u4e0a\u3052\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2014\/08\/18\/rails-development-on-docker\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[137,22],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/4319"}],"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\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=4319"}],"version-history":[{"count":18,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/4319\/revisions"}],"predecessor-version":[{"id":4337,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/4319\/revisions\/4337"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=4319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=4319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=4319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}