{"id":2867,"date":"2017-11-17T15:37:19","date_gmt":"2017-11-17T14:37:19","guid":{"rendered":"http:\/\/wordpress.networknet.nl\/?p=2867"},"modified":"2017-11-17T15:37:19","modified_gmt":"2017-11-17T14:37:19","slug":"azure-devtest-lab-run-mysql-and-wordpress-docker-container","status":"publish","type":"post","link":"https:\/\/www.networknet.nl\/apps\/wp\/archives\/2867","title":{"rendered":"Azure DevTest Lab: run mysql and wordpress docker container"},"content":{"rendered":"<p>\n\tIt has been a long while ago I logged on a linux console and played around to install some packages. Currently working on a course for &ldquo;Developing Microsoft Azure Solutions (70-532)&rdquo; where I learned what DevTest Labs is and spin off an Ubuntu server image with the Docker package (as artifact option). I like this concept&nbsp; around DevTest principle to create images, configure and make them available to developers, IT or the end users to test the applications.\n<\/p>\n<p>\n\t<a href=\"https:\/\/www.networknet.nl\/apps\/wp\/wp-content\/uploads\/2017\/11\/image.png\"><img decoding=\"async\" alt=\"image\" src=\"https:\/\/www.networknet.nl\/apps\/wp\/wp-content\/uploads\/2017\/11\/image_thumb.png\" style=\"display: inline; background-image: none; border-width: 0px; border-style: solid; width: 700px; height: 198px;\" title=\"image\" \/><\/a>\n<\/p>\n<p>\n\tUbuntu server was running and I could connect with SSH to it. So I did and now I needed to find my way around. It all worked out with help from&nbsp;google to find the proper command set to get my WordPress site up and running. I knew what docker was and wanted to get it working myself.\n<\/p>\n<h2>\n\tDocker<br \/>\n<\/h2>\n<h3>\n\tInstall and configure mysql database engine and load WordPress<br \/>\n<\/h3>\n<pre class=\"brush:bash\">\r\n#update Ubuntu and verify docker is working\r\nsudo apt-get update\r\nsudo docker run hello-world\r\n#restart docker daemon\r\nsudo service docker restart\r\n#create wordpress folder\r\nmkdir ~\/wordpress &amp;&amp; cd ~\/wordpress\r\n#install mariadb engine for mysql \r\nsudo docker run -e MYSQL_ROOT_PASSWORD=1234567ABC -e MYSQL_DATABASE=wordpress --name wordpressdb -v &quot;$PWD\/database&quot;:\/var\/lib\/mysql -d mariadb:latest\r\n#verify the mariadb container\r\nsudo docker ps\r\n#download wordpress container\r\nsudo docker pull wordpress\r\n#run wordpress container, make sure to use right tcp port (8080 is the one I will be creating NAT rule to my Ubuntu server)\r\nsudo docker run -e WORDPRESS_DB_PASSWORD=1234567ABC --name wordpress --link wordpressdb:mysql -p 8080:80 -v &quot;$PWD\/html&quot;:\/var\/www\/html -d wordpress<\/pre>\n<p>\n\tI completed the steps above and tried to connect to the Ubuntu server over tcp\/8080 port. After some additional reading on google and finding my way in the DevTest Lab resources I figured out I need to create additional inbound NAT rule and point that to my VM and the 8080 port I configured in the &ldquo;sudo docker run with option &ndash;p&rdquo;\n<\/p>\n<p>\n\t<a href=\"https:\/\/www.networknet.nl\/apps\/wp\/wp-content\/uploads\/2017\/11\/image-1.png\"><img decoding=\"async\" alt=\"image\" src=\"https:\/\/www.networknet.nl\/apps\/wp\/wp-content\/uploads\/2017\/11\/image_thumb-1.png\" style=\"display: inline; background-image: none; border-width: 0px; border-style: solid; width: 700px; height: 268px;\" title=\"image\" \/><\/a>\n<\/p>\n<p>\n\tI run following command to verify local connectivity from the Ubuntu server\n<\/p>\n<p>\n\tcurl -I 10.0.0.4:8080\n<\/p>\n<pre class=\"brush:bash\">\r\n@UbuntuServer:~$ curl -I 10.0.0.4:8080\r\nHTTP\/1.1 301 Moved Permanently\r\nDate: Fri, 17 Nov 2017 09:49:13 GMT\r\nServer: Apache\/2.4.10 (Debian)\r\nX-Powered-By: PHP\/5.6.32\r\nLocation: http:\/\/ubuntu1234.westeurope.cloudapp.azure.com:8080\/\r\nContent-Type: text\/html; charset=UTF-8\r\n@UbuntuServer:~$<\/pre>\n<p>\n\tOutput looks good and so I opened IE and followed the steps for WordPress installation of a new site.\n<\/p>\n<p>\n\tOne thing that I learned is when installing the containers for docker you will need to update the restart option of the container, otherwise after server reboot the containers won&rsquo;t run. I run the following two commands and fixed that problem.\n<\/p>\n<pre class=\"brush:bash\">\r\nsudo docker update --restart always wordpressdb\r\nsudo docker update --restart always wordpress<\/pre>\n<p>\n\tFrom now on I will maintain my own Ubuntu server ,continue to explore docker containers and refresh my linux knowledge.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It has been a long while ago I logged on a linux console and played around to install some packages. Currently working on a course for &ldquo;Developing Microsoft Azure Solutions (70-532)&rdquo; where I learned what DevTest Labs is and spin off an Ubuntu server image with the Docker package (as artifact option). I like this concept&nbsp; around DevTest principle to create images, configure and make them available to developers, IT or the end users to test the applications. Ubuntu server was running and I could connect with SSH to it. So I did and now I needed to find my way around. It all worked out with help from&nbsp;google to find the proper command set to get my WordPress site up and running. I knew what docker was and wanted to get it working myself. Docker Install and configure mysql database engine and load WordPress #update Ubuntu and verify docker is working sudo apt-get update sudo docker run hello-world #restart docker daemon sudo service docker restart #create wordpress folder mkdir ~\/wordpress &amp;&amp; cd ~\/wordpress #install mariadb engine for mysql sudo docker run -e MYSQL_ROOT_PASSWORD=1234567ABC -e MYSQL_DATABASE=wordpress &#8211;name wordpressdb -v &quot;$PWD\/database&quot;:\/var\/lib\/mysql -d mariadb:latest #verify the mariadb container sudo docker ps #download wordpress container sudo docker pull wordpress #run wordpress container, make sure to use right tcp port (8080 is the one I will be creating NAT rule to my Ubuntu server) sudo docker run -e WORDPRESS_DB_PASSWORD=1234567ABC &#8211;name wordpress &#8211;link wordpressdb:mysql -p 8080:80 -v &quot;$PWD\/html&quot;:\/var\/www\/html -d wordpress I completed the steps above [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[839,51,499],"tags":[841,842,840],"class_list":["post-2867","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-microsoft","category-wordpress-opensource","tag-azure","tag-devtest","tag-docker"],"_links":{"self":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts\/2867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/comments?post=2867"}],"version-history":[{"count":5,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts\/2867\/revisions"}],"predecessor-version":[{"id":2875,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts\/2867\/revisions\/2875"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/media\/2873"}],"wp:attachment":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/media?parent=2867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/categories?post=2867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/tags?post=2867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}