{"id":1455,"date":"2016-05-31T09:52:58","date_gmt":"2016-05-31T00:52:58","guid":{"rendered":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/?page_id=1455"},"modified":"2016-06-02T18:02:33","modified_gmt":"2016-06-02T09:02:33","slug":"kusanagi-runs-on-docker","status":"publish","type":"page","link":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/cloud\/kusanagi-runs-on-docker\/","title":{"rendered":"KUSANAGI Runs on Docker"},"content":{"rendered":"<p>This guide will explain how to create a WordPress environment using <em>KUSANAGI Runs on Docker<\/em> (<em>KUSANAGI RoD<\/em>).<\/p>\n<h1 id=\"-\">Overview<\/h1>\n<p><em>KUSANAGI RoD<\/em> runs the Ultrafast WordPress Virtual Machine KUSANAGI on a Docker Machine.<br \/>\n<em>KUSANAGI RoD<\/em> offers the same high speed WordPress execution environment as KUSANAGI, but since it is in beta, the following restrictions apply.<\/p>\n<ul>\n<li><strong>\u30fbOperating environment<\/strong><br \/>\nYou can use Nginx, PHP 7, PHP 5 and MariaDB.<br \/>\nWe will expand to Apache2(httpd) and HHVM at a later time.<\/li>\n<li><strong>\u30fbKUSANAGI commands<\/strong><br \/>\nYou cannot use KUSANAGI commands.<br \/>\nThe &#8220;kusanagi provision&#8221; and\u00a0 &#8220;bcache\/fcache&#8221; commands are performed by editing &#8220;docker-compose.yml&#8221;<\/li>\n<li><strong>\u30fbSSL<\/strong><br \/>\nYou cannot use Let&#8217;s Encrypt&#8217;s SSL service.<br \/>\nWe will add SSL support at a later time.<\/li>\n<\/ul>\n<h1 id=\"-\">Installation<\/h1>\n<p>You need Docker, Docker Machine, and Docker Compose to use <em>KUSANAGI RoD<\/em>.<br \/>\nInstallation instructions are as follows.<\/p>\n<h2 id=\"docker\">Docker<\/h2>\n<p>Choose the Docker installation for your OS.<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.docker.com\/engine\/installation\/windows\/\">Docker for Windows<\/a><\/li>\n<li><a href=\"https:\/\/docs.docker.com\/engine\/installation\/mac\/\">Docker for Mac OS X<\/a><\/li>\n<li><a href=\"https:\/\/docs.docker.com\/engine\/installation\/\">Docker Engine for Linux<\/a><\/li>\n<\/ul>\n<h2 id=\"docker-machine\">Docker Machine<\/h2>\n<p>Install Docker Machine from the following:<\/p>\n<ul>\n<li><a href=\"http:\/\/docs.docker.jp\/machine\/index.html\">Docker Machine<\/a><\/li>\n<\/ul>\n<h2 id=\"docker-compose\">Docker Compose<\/h2>\n<p>Install Docker Compose from the following:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.docker.com\/compose\/\">Docker Compose<\/a><\/li>\n<li><a href=\"https:\/\/docs.docker.com\/compose\/install\/\">Mac OS X\/Ubuntu<\/a><\/li>\n<\/ul>\n<p>On Windows, installing Docker Toolbox will install Docker Compose as well.<\/p>\n<h1 id=\"docker-machine-\">Create a Docker Machine<\/h1>\n<p>You can control Docker using your Docker Machine on the local VirtualBox or a cloud platform (such as Microsoft Azure, AWS EC2, etc.)<\/p>\n<h2 id=\"virtualbox-\">On VirtualBox<\/h2>\n<p>View <a href=\"https:\/\/docs.docker.com\/machine\/get-started\/\">Get started with Docker Machine and a local VM<\/a> and create a Docker Machine on VirtualBox. In the following example, we created the Docker Machine &#8220;kusanagi-machine&#8221;.<\/p>\n<pre><code># docker-machine <span class=\"hljs-operator\"><span class=\"hljs-keyword\">create<\/span> <span class=\"hljs-comment\">--driver virtualbox --virtualbox-memory=8192 --virtualbox-cpu-count=2 kusanagi-machine<\/span><\/span>\r\n<\/code><\/pre>\n<p>Use the following command to confirm the details of your Docker Machine.<\/p>\n<pre><code><span class=\"hljs-preprocessor\"># docker-machine ls                                                                 <\/span>\r\nNAME                    ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS         \r\nkusanagi-machine        *        virtualbox   Running   tcp:<span class=\"hljs-comment\">\/\/192.168.99.100:2376           v1.11.1 <\/span>\r\n<span class=\"hljs-preprocessor\"># docker-machine env kusanagi-machine<\/span>\r\n<span class=\"hljs-keyword\">export<\/span> DOCKER_TLS_VERIFY=<span class=\"hljs-string\">\"1\"<\/span>\r\n<span class=\"hljs-keyword\">export<\/span> DOCKER_HOST=<span class=\"hljs-string\">\"tcp:\/\/192.168.99.100:2376\"<\/span>\r\n<span class=\"hljs-keyword\">export<\/span> DOCKER_CERT_PATH=<span class=\"hljs-string\">\"\/root\/.docker\/machine\/machines\/kusanagi-machine\"<\/span>\r\n<span class=\"hljs-keyword\">export<\/span> DOCKER_MACHINE_NAME=<span class=\"hljs-string\">\"kusanagi-machine\"<\/span>\r\n<span class=\"hljs-preprocessor\"># Run this command to configure your shell:<\/span>\r\n<\/code><\/pre>\n<h2 id=\"azure-\">On Azure<\/h2>\n<p>View <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/virtual-machines-linux-docker-machine\/\">Use Docker Machine with the Azure driver<\/a> and create a Docker Machine on Microsoft Azure. In the following example, we created the Docker Machine &#8220;kusanagi-machine&#8221;. We set our region as Japan East, and the VM size to Standard_D1.<\/p>\n<pre><code># docker-machine <span class=\"hljs-operator\"><span class=\"hljs-keyword\">create<\/span> -d azure <span class=\"hljs-comment\">--azure-ssh-user rod \\<\/span>\r\n  <span class=\"hljs-comment\">--azure-subscription-id &lt;Your AZURE_SUBSCRIPTION_ID&gt; \\<\/span>\r\n  <span class=\"hljs-comment\">--azure-location \"Japan East\" \\<\/span>\r\n  <span class=\"hljs-comment\">--azure-size \"Standard_D1\" \\<\/span>\r\n  <span class=\"hljs-comment\">--azure-open-port 80 \\<\/span>\r\n  kusanagi-azure<\/span>\r\n<\/code><\/pre>\n<p>Occasionally you will be asked to verify your account, so access the webpage shown and enter the code.<\/p>\n<pre><code>(kusanagi-azure) Microsoft Azure: To sign in, <span class=\"hljs-operator\"><span class=\"hljs-keyword\">use<\/span> a web browser <span class=\"hljs-keyword\">to<\/span> <span class=\"hljs-keyword\">open<\/span> the page https:\/\/aka.ms\/devicelogin. Enter the code XXXXXXXXX <span class=\"hljs-keyword\">to<\/span> authenticate.<\/span>\r\n<\/code><\/pre>\n<p>Use the following command to confirm the details of your Docker Machine.<\/p>\n<pre><code><span class=\"hljs-preprocessor\"># docker-machine ls kusanagi-azure                                           <\/span>\r\nNAME               ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS\r\nkusanagi-azure     -        azure        Running   tcp:<span class=\"hljs-comment\">\/\/XXX.XXX.XXX.XXX:2376              v1.11.1 <\/span>\r\n<span class=\"hljs-preprocessor\"># docker-machine env kusanagi-azure<\/span>\r\n<span class=\"hljs-keyword\">export<\/span> DOCKER_TLS_VERIFY=<span class=\"hljs-string\">\"1\"<\/span>\r\n<span class=\"hljs-keyword\">export<\/span> DOCKER_HOST=<span class=\"hljs-string\">\"tcp:\/\/XXX.XXX.XXX.XXX:2376\"<\/span>\r\n<span class=\"hljs-keyword\">export<\/span> DOCKER_CERT_PATH=<span class=\"hljs-string\">\"\/root\/.docker\/machine\/machines\/kusanagi-azure\"<\/span>\r\n<span class=\"hljs-keyword\">export<\/span> DOCKER_MACHINE_NAME=<span class=\"hljs-string\">\"kusanagi-azure\"<\/span>\r\n<span class=\"hljs-preprocessor\"># Run this command to configure your shell: <\/span>\r\n<span class=\"hljs-preprocessor\"># eval $(docker-machine env kusanagi-azure)<\/span>\r\n<\/code><\/pre>\n<h1 id=\"docker-compose-kusanagi-rod-\">Create KUSANAGI RoD with Docker Compose<\/h1>\n<p>Next we will create <em>KUSANAGI RoD<\/em> by using Docker Compose.<\/p>\n<ul>\n<li>(1) Download kusanagi-docker from GitHub.<\/li>\n<\/ul>\n<pre><code>\uff03 git <span class=\"hljs-keyword\">clone<\/span> https:<span class=\"hljs-comment\">\/\/github.com\/prime-strategy\/kusanagi-docker.git<\/span>\r\n<span class=\"hljs-comment\"># cd kusanagi-docker<\/span>\r\n<span class=\"hljs-comment\"># ls -A                                                                                                            <\/span>\r\n.git   LICENSE  README.md\r\n<\/code><\/pre>\n<ul>\n<li>(2) Like the README states, create &#8220;docker-compose.yml&#8221;. In the following example we created it using nginx-1.10.0-1 and php-7.0.6.<\/li>\n<li><\/li>\n<li>\n<pre><code># cat docker-compose.yml\r\nversion: <span class=\"hljs-string\">'2'<\/span>\r\n\r\nservices:\r\n  kusanagi-data:\r\n    container_name: kusanagi-data\r\n    image: busybox\r\n    restart: always\r\n    stdin_open: <span class=\"hljs-literal\">true<\/span>\r\n    tty: <span class=\"hljs-literal\">true<\/span>\r\n    volumes:\r\n      - <span class=\"hljs-regexp\">\/var\/<\/span>lib\/mysql\r\n      - <span class=\"hljs-regexp\">\/etc\/<\/span>nginx\/conf.d\r\n      - <span class=\"hljs-regexp\">\/etc\/<\/span>httpd\/conf.d\r\n      - <span class=\"hljs-regexp\">\/etc\/<\/span>kusanagi.d\r\n      - <span class=\"hljs-regexp\">\/home\/<\/span>kusanagi\r\n    command: <span class=\"hljs-regexp\">\/bin\/<\/span>sh\r\n\r\n  kusanagi-nginx:\r\n    container_name: kusanagi-nginx\r\n    image: primestrategy\/kusanagi-nginx:<span class=\"hljs-number\">1.10<\/span><span class=\"hljs-number\">.0<\/span>-<span class=\"hljs-number\">1<\/span>\r\n    environment:\r\n      PROFILE: kusanagi\r\n      FQDN: kusanagi.example.jp\r\n      WPLANG: ja\r\n      BCACHE: <span class=\"hljs-string\">\"off\"<\/span>\r\n      FCACHE: <span class=\"hljs-string\">\"off\"<\/span>\r\n    volumes_from:\r\n      - kusanagi-data\r\n    links:\r\n      - kusanagi-php7:php\r\n      - kusanagi-mariadb:mysql\r\n    ports:\r\n      - <span class=\"hljs-string\">\"80:80\"<\/span>\r\n      - <span class=\"hljs-string\">\"443:443\"<\/span>\r\n\r\n  kusanagi-mariadb:\r\n    container_name: kusanagi-mariadb\r\n    image: mariadb:<span class=\"hljs-number\">10.0<\/span><span class=\"hljs-number\">.24<\/span>\r\n    environment:\r\n      MYSQL_ROOT_PASSWORD: my-secret-pw\r\n      MYSQL_USER:     user\r\n      MYSQL_PASSWORD: password\r\n      MYSQL_DATABASE: wordpress\r\n    volumes_from:\r\n      - kusanagi-data\r\n\r\n  kusanagi-php7:\r\n    container_name: kusanagi-php7\r\n    image: primestrategy\/kusanagi-php7:<span class=\"hljs-number\">7.0<\/span><span class=\"hljs-number\">.6<\/span>-<span class=\"hljs-number\">1<\/span>\r\n    links:\r\n      - kusanagi-mariadb:mysql\r\n    volumes_from:\r\n      - kusanagi-data\r\n<\/code><\/pre>\n<\/li>\n<li><\/li>\n<li>(3) Change your settings<br \/>\nEdit &#8220;docker-compose.yml&#8221; to change the environment variables.<\/p>\n<ul>\n<li><strong>kusanagi-nginx<\/strong><\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>explanation<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>PROFILE<\/td>\n<td>Profile name created with kusanagi provision<\/td>\n<\/tr>\n<tr>\n<td>FQDN<\/td>\n<td>Host name identified in kusanagi provision<\/td>\n<\/tr>\n<tr>\n<td>WPLANG<\/td>\n<td>Language selected in kusanagi provision (en, ja)<\/td>\n<\/tr>\n<tr>\n<td>BCACHE<\/td>\n<td>Turn bcache on or off<\/td>\n<\/tr>\n<tr>\n<td>FCACHE<\/td>\n<td>Turn fcache on or off<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li><strong>kusanagi-mariadb<\/strong><\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>explanation<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>MYSQL_ROOT_PASSWORD<\/td>\n<td>MySQL root user password<\/td>\n<\/tr>\n<tr>\n<td>MYSQL_USER<\/td>\n<td>WordPress user name<\/td>\n<\/tr>\n<tr>\n<td>MYSQL_PASSWORD<\/td>\n<td>WordPress password<\/td>\n<\/tr>\n<tr>\n<td>MYSQL_DATABASE<\/td>\n<td>WordPress database name<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><\/li>\n<li>(4) Configure the Docker environment<br \/>\nName your Docker Machine and perform the settings needed in order to use Docker Compose.<\/li>\n<li><\/li>\n<li>\n<pre><code># <span class=\"hljs-built_in\">eval<\/span> $(docker-machine env kusanagi-azure)\r\n<\/code><\/pre>\n<\/li>\n<li><\/li>\n<li>(5) Use docker-compose.yml to boot Docker using your Docker Machine.<\/li>\n<li><\/li>\n<li>\n<pre><code><span class=\"hljs-comment\"># docker-compose -p kusanagi-azure up<\/span>\r\n<span class=\"hljs-comment\"># docker-compose -p kusanagi-azure ps<\/span>\r\n      <span class=\"hljs-title\">Name<\/span>                    Command               State                    Ports                   \r\n----------------------------------------------------------------------------------------------------\r\nkusanagi-data      \/bin\/sh                          Up  \r\nkusanagi-mariadb   \/docker-entrypoint.sh mysqld     Up      <span class=\"hljs-number\">3306<\/span>\/tcp\r\nkusanagi-nginx     \/docker-entrypoint.sh \/usr ...   Up      <span class=\"hljs-number\">0.0.0.0:443<\/span>-&gt;<span class=\"hljs-number\">443<\/span>\/tcp, <span class=\"hljs-number\">0.0.0.0:80<\/span>-&gt;<span class=\"hljs-number\">80<\/span>\/tcp \r\nkusanagi-php7      php-fpm                          Up      <span class=\"hljs-number\">9000<\/span>\/tcp\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2 id=\"wordpress-\">WordPress Settings<\/h2>\n<p>Go to the host you identified in &#8220;docker-compose.yml&#8221; and you should be able to install WordPress. Use the following settings:<\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>explanation<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Database Name<\/td>\n<td>Same as MYSQL_DATABASE. Above example is <strong>wordpress<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Username<\/td>\n<td>Same as MYSQL_USER. Above example is <strong>user<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Password<\/td>\n<td>Same as MYSQL_PASSWORD. Above example is <strong>password<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Database Host<\/td>\n<td>MySQL host name identified during kusanagi-nginx setup. Above example is <strong>mysql<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Table Prefix<\/td>\n<td>Optional. Default is <strong>wp_<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>This guide will explain how to create a WordPress environment using KUSANAGI Runs on Docker (KUSANAGI RoD). Overview KUSANAGI RoD runs the Ultrafast WordPress Virtual Machine KUSANAGI on a Docker Machine. KUSANAGI RoD offers the same high speed WordPress execution environment as KUSANAGI, but since it is in beta, the following restrictions apply. \u30fbOperating environment [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":49,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-1455","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/pages\/1455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/comments?post=1455"}],"version-history":[{"count":7,"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/pages\/1455\/revisions"}],"predecessor-version":[{"id":1561,"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/pages\/1455\/revisions\/1561"}],"up":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/pages\/49"}],"wp:attachment":[{"href":"https:\/\/kusanagi.tokyo\/en-kusanagi8\/wp-json\/wp\/v2\/media?parent=1455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}