{"id":76,"date":"2015-11-09T07:21:58","date_gmt":"2015-11-09T07:21:58","guid":{"rendered":"http:\/\/cloudkul.com\/blog\/?p=76"},"modified":"2017-06-14T11:34:44","modified_gmt":"2017-06-14T11:34:44","slug":"dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/","title":{"rendered":"Dockerize  Joomla : Virtualize your CMS within a light-weighted container"},"content":{"rendered":"<p><strong>Why we need Docker Containers : Take A Quick Look\u00a0<\/strong><\/p>\n<p>Dependency hell is something that the application developers are dealing with for a very long time and what it means is, i build my application on my development machine, it works great, then i deploy my application to the production environment but it doesn&#8217;t work.<\/p>\n<p>Hey developer, your application doesn&#8217;t work in our environment, fix it. Hey sysadmin, it works fine in my environment, why doesn&#8217;t it work in your environment?\u00a0Therefore, it leaves system admin and developers pointing fingers at each other. Here, the concept of docker containers came into picture.<\/p>\n<p>Containers are completely isolated environment.The application only needs to run inside the container which means that the operating system,underlying host and the environment that it runs on is completely abstracted from the application and therefore it successfully solves the problem of dependencies.<\/p>\n<p>So if you are also dealing with such kind of problems within your content management system, this blog will definitely help you out. Here, we are taking joomla as a CMS which enables you to build websites and powerful online applications. Here we go !!<\/p>\n<p><strong>Understanding the scenario :<\/strong><\/p>\n<p>When using docker, we start with a base image. We boot it up, do changes and the changes are saved in layers forming another image. Basically, there are following two ways to create an image :-<\/p>\n<p>Interactively, by running a shell from a base image and manually installing the required software.<br \/>\nImperatively, by defining a series of commands inside a Dockerfile.<br \/>\nThe first approach is undoubtedly better when experimenting or finding your feet, but when you want to start building reliable, reusable images I\u2019ve found using a Dockerfile a must. So, we will go ahead with the latter one.<\/p>\n<p>An instance of an image is called container. You have an image, which is a set of layers as you have described it by yourself. If you start this image, you have a running container of this image. You can have many running containers of the same image. To see all of your images and containers, run the following commands :-<\/p>\n<pre class=\"lang:default decode:true \">docker images\r\n\r\ndocker ps<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Dockerfile of our base image : webkul\/joomla<\/strong><\/p>\n<pre class=\"lang:default decode:true \">FROM ubuntu:14.04\r\nMAINTAINER Naina Johari &lt;naina.johari379@webkul.com&gt;\r\n\r\n# Update existing packages &amp; install LAMPSTACK\r\nRUN apt-get update\r\nRUN apt-get install -y lamp-server^ &amp;&amp; \\\r\napt-get install -y wget curl unzip \r\nRUN apt-get install -y libapache2-mod-php5 php5-mcrypt php5-gd pwgen\r\n\r\n\r\n# Download Joomla\r\nADD https:\/\/github.com\/joomla\/joomla-cms\/releases\/download\/3.4.1\/Joomla_3.4.1-Stable-Full_Package.zip \/tmp\/\r\n\r\n# Remove previous files of default document root\r\nRUN rm -rf \/var\/www\/html\/*\r\n\r\n# Extract Joomla\r\nRUN cd \/tmp &amp;&amp; unzip -q Joomla*.zip -d \/var\/www\/html\r\n\r\n# Grant permission of the directory to apache2\r\nRUN chown -R www-data:www-data \/var\/www\/html &amp;&amp; \\\r\nchmod -R 755 \/var\/www\/html\r\n\r\nRUN sed -i -e\"s\/^bind-address\\s*=\\s*127.0.0.1\/bind-address = 0.0.0.0\/\" \/etc\/mysql\/my.cnf\r\nRUN apt-get install -y supervisor\r\nRUN mkdir -p \/var\/log\/supervisor\r\nRUN php5enmod mcrypt\r\n\r\nADD startupscript.sh \/etc\/startupscript.sh\r\nADD supervisord.conf \/etc\/supervisor\/conf.d\/supervisord.conf\r\nADD adminer.php \/var\/www\/html\/joomla\r\nADD create_mysql_admin_user.sh \/create_mysql_admin_user.sh\r\nRUN chmod 755 \/create_mysql_admin_user.sh\r\nRUN .\/create_mysql_admin_user.sh &gt; \/credentials.txt\r\n\r\nEXPOSE 80\r\nEXPOSE 3306\r\n\r\nCMD [\"\/usr\/bin\/supervisord\"]\r\n\r\n<\/pre>\n<p>Pull our docker image for joomla directly from dockerhub using the following command :-<\/p>\n<pre class=\"lang:default decode:true \">docker pull webkul\/joomla<\/pre>\n<p>Check if you have successfully downloaded the image locally on your system :-<\/p>\n<pre class=\"lang:default decode:true \">docker images<\/pre>\n<p>You must find <strong>webkul\/joomla<\/strong> as an output of this command.<\/p>\n<p>Run a container of this image using the following command :-<\/p>\n<pre class=\"lang:default decode:true \">docker run -d -p 80:80 -p 3306:3306 webkul\/joomla:latest<\/pre>\n<div class=\"panel panel-info\">\n<div class=\"panel-heading\">Note<\/div>\n<div class=\"panel-body\">\n<p>\nNo other services should be running on port 80 and 3306 of your host system. If so, change ports in the above docker command.\n<\/p>\n<\/div>\n<\/div>\n<p>Access the URL to install joomla on your system :-<\/p>\n<pre class=\"lang:default decode:true \">http:\/\/server_domain_name_or_IP\/joomla<\/pre>\n<p>In order to access the credentials of your database, you have to get the container&#8217;s console. Run the following command :-<\/p>\n<pre class=\"lang:default decode:true \">docker exec -it $container_id \u00a0bash<\/pre>\n<p>You are supposed to run &#8220;docker ps&#8221; to know container&#8217;s id before you run the above command.<\/p>\n<p>Within container,read the content of the file named password.txt to access your mysql database username and password by running :-<\/p>\n<pre class=\"lang:default decode:true \">cat \/password.txt<\/pre>\n<p>Once your mysql username and password is known to you, you can simply login to mysql and create database accordingly.<\/p>\n<p>For Reference :-\u00a0<a href=\"https:\/\/hub.docker.com\/webkul\/joomla\">https:\/\/hub.docker.com\/webkul\/joomla<\/a><\/p>\n<p>For Source Code :- \u00a0<a href=\"https:\/\/github.com\/webkul\/docker_joomla\">https:\/\/github.com\/webkul\/docker_joomla<\/a><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/cloudkul.com\/contact\/\" target=\"_blank\">FOR ANY TYPE OF QUERY OR HELP, KINDLY CONTACT US<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why we need Docker Containers : Take A Quick Look\u00a0 Dependency hell is something that <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":5,"featured_media":349,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Dockerize Joomla : Virtualize your CMS within a light-weighted container - Cloudkul<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dockerize Joomla : Virtualize your CMS within a light-weighted container - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"Why we need Docker Containers : Take A Quick Look\u00a0 Dependency hell is something that [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-09T07:21:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-14T11:34:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2015\/11\/Ubuntu-Base-Docker.png\" \/>\n\t<meta property=\"og:image:width\" content=\"848\" \/>\n\t<meta property=\"og:image:height\" content=\"422\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Naina Johari\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/\",\"name\":\"Dockerize Joomla : Virtualize your CMS within a light-weighted container - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2015-11-09T07:21:58+00:00\",\"dateModified\":\"2017-06-14T11:34:44+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Dockerize Joomla : Virtualize your CMS within a light-weighted container\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57\",\"name\":\"Naina Johari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Naina Johari\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Dockerize Joomla : Virtualize your CMS within a light-weighted container - Cloudkul","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/","og_locale":"en_US","og_type":"article","og_title":"Dockerize Joomla : Virtualize your CMS within a light-weighted container - Cloudkul","og_description":"Why we need Docker Containers : Take A Quick Look\u00a0 Dependency hell is something that [...]","og_url":"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/","og_site_name":"Cloudkul","article_published_time":"2015-11-09T07:21:58+00:00","article_modified_time":"2017-06-14T11:34:44+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2015\/11\/Ubuntu-Base-Docker.png","type":"image\/png"}],"author":"Naina Johari","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/","url":"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/","name":"Dockerize Joomla : Virtualize your CMS within a light-weighted container - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2015-11-09T07:21:58+00:00","dateModified":"2017-06-14T11:34:44+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/dockerize-joomla-virtualize-your-cms-within-a-light-weighted-container\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Dockerize Joomla : Virtualize your CMS within a light-weighted container"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57","name":"Naina Johari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Naina Johari"},"url":"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/76"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":4,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":424,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions\/424"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/349"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}