{"id":3313,"date":"2017-09-06T14:11:20","date_gmt":"2017-09-06T14:11:20","guid":{"rendered":"https:\/\/cloudkul.com\/blog\/?p=3313"},"modified":"2018-07-17T09:25:08","modified_gmt":"2018-07-17T09:25:08","slug":"magento-2-docker-compose","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/","title":{"rendered":"Magento 2 With Docker-Compose"},"content":{"rendered":"<h2><\/h2>\n<p>In our last <a href=\"https:\/\/cloudkul.com\/blog\/magento-2-docker-installation\/\">blog<\/a>, we had discussed briefly about Docker architecture and its three components. We had also setup an architecture for Magento 2 having apache server and mysql server running on same container. Also, by mounting Magento 2 files from host to container, we had setup <strong><em>single docker container<\/em><\/strong> architecture for Magento 2.<\/p>\n<p>Although, for multiple-server production environment, <em><strong>single Docker container architecture is not a good\u00a0choice <\/strong><\/em>as it lacks scalability and flexibility. <em><strong>Single Docker container architecture can be opt in the case when your backend server setup is not going to get frequently modified.<\/strong><\/em><\/p>\n<p>For long run, multiple docker container architecture is a good way to go. Also, as we have discussed in our last blog that <em><strong>there should be single process running per container<\/strong><\/em>, so for a LAMP server setup, apache server and mysql server should\u00a0run on separate containers interlinked with each other.<\/p>\n<p>In order to achieve multiple containers architecture, we can\u00a0use docker-compose tool.<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Introduction to Docker-Compose<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<p>Quoting from Docker docs itself,<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p><em><strong>Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application\u2019s services. Then, using a single command, you create and start all the services from your configuration.<\/strong><\/em><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>With the help of docker-compose we can define containers to be built, their configuration, links, volumes, ports etc in a single file and it gets launched by a single command. We can add multiple servers and services just by adding them to docker-compose configuration file. This configuration file is in YAML format.<\/p>\n<p>Working with docker-compose is generally few steps process:<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><em><strong>Create a Dockerfile defining the application environment.<\/strong><\/em> We can create separate Dockerfile for our different services. As Dockerfile are lightweight, so our application can be replicated anywhere.<\/li>\n<li><em><strong>Create a docker-compose.yml file defining services that needed for application run.\u00a0<\/strong><\/em>We can define volumes to be mapped, ports to be exposed, links to be created, arguments to be passed etc in our docker-compose.yml file.<\/li>\n<li><em><strong>Run &#8216;docker-compose build&#8217; to create Docker image.\u00a0<\/strong><\/em>After creating Dockerfile, docker-compose.yml and placing our volumes at right places, we can create our image.<\/li>\n<li><em><strong>Run &#8216;docker-compose up -d&#8217; to run the docker containers.\u00a0<\/strong><\/em>After image build up, we can run all of our containers as mentioned in configuration files by this single command.<\/li>\n<\/ul>\n<h2><\/h2>\n<p>&nbsp;<\/p>\n<h2>Setting Up Magento 2 Using\u00a0Docker-Compose<\/h2>\n<p>&nbsp;<\/p>\n<p>In this blog, <em><strong>we will be using same architecture as mentioned above to setup Magento 2 using docker-compose on Ubuntu 16.04<\/strong> <\/em>. Presuming that fact that docker and docker-compose is already installed on your ubuntu server we will begin with server setup. If not, please install <a href=\"https:\/\/docs.docker.com\/engine\/installation\/linux\/docker-ce\/ubuntu\/\">docker<\/a> and <a href=\"https:\/\/docs.docker.com\/compose\/install\/#upgrading\">docker-compose<\/a> first.<\/p>\n<p>Our parent directory holding all the files\/directories will be considered as project name. We can also set custom project name in docker-compose.yml file. Here we are creating separate directories for apache2 and mysql server setup that holds Dockerfile and their associated volumes.<\/p>\n<p>Take a note that: Like our previous blog,\u00a0<em><strong>Magento 2 files will be placed on our host. As it is a good practice to keep application files on host so that it will not be lost if containers or images get accidentally removed. These magento files will be mapped from host to running docker container<\/strong>.<\/em><\/p>\n<p>We are also using supervisor to control apache2 server and mysql server in their respective containers. Apart from controlling these servers, supervisor is also running various commands and scripts that will be mentioned later in this blog.<\/p>\n<p>To begin with create a directory on your Ubuntu 16.04 server for this project. Our directory architecture will be something like:<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>docker-compose.yml<\/strong><\/li>\n<li><strong>web_server\u00a0<\/strong><\/li>\n<\/ul>\n<blockquote><p><em>Dockerfile<\/em><\/p>\n<p><em>supervisord.conf<\/em><\/p><\/blockquote>\n<ul>\n<li><strong>\u00a0database_server<\/strong><\/li>\n<\/ul>\n<blockquote><p><em>Dockerfile<\/em><\/p>\n<p><em>mysql.sh<\/em><\/p>\n<p><em>supervisord.conf<\/em><\/p><\/blockquote>\n<ul>\n<li><strong>magento2<\/strong><\/li>\n<\/ul>\n<blockquote><p><em>Unarchived Magento 2 files and directories.<\/em><\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<p>The<em> docker-compose.yml<\/em> file is shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">version: '3'\r\nservices:\r\n  web_server:\r\n    build:\r\n      context: .\/web_server\/\r\n    container_name: apache2\r\n    volumes:\r\n      - .\/magento2:\/var\/www\/html\r\n      - .\/web_server\/supervisord.conf:\/etc\/supervisor\/conf.d\/supervisord.conf\r\n    ports:\r\n      - \"80:80\"\r\n    links:\r\n      - database_server\r\n\r\n  database_server:\r\n    build:\r\n      context: .\/database_server\/\r\n      args:\r\n        - mysql_password=mention_your_mysql_root_password\r\n        - mysql_database=mention_your_database_name\r\n    container_name: mysql\r\n    volumes: \r\n      - .\/database_server\/supervisord.conf:\/etc\/supervisor\/conf.d\/supervisord.conf\r\n      - .\/database_server\/mysql.sh:\/etc\/mysql.sh\r\n    ports:\r\n- \"3306:3306\"<\/pre>\n<p>&nbsp;<\/p>\n<p>As we can see in docker-compose.yml file above, among various version available, we are using version 3. Here in our configuration file, we are defining two services: web_server and database_server. The web_server is associated with our apache2 server configuration. Container name defined for this service is apache2, linked to database_server and port 80 is allocated to it. There are four volumes or files are being mapped from host to docker container and &#8220;context&#8221; under &#8220;build&#8221; points to location of its Dockerfile.<\/p>\n<p>Also, the service database_server is associated with mysql-server. Container name is defined as mysql and port 3306 is allocated to it. Mysql root password and Database name will be passed as build argument and there are two volumes\/files mapped from host to docker container. Same as web_server, &#8220;context&#8221; points to location of its Dockerfile.<\/p>\n<p>Lets take a look in our <em>web_server directory<\/em>. It contains 2 files. <em>Dockerfile<\/em> is shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">FROM ubuntu:16.04\r\n\r\nLABEL maintainer=\"Alankrit Srivastava &lt;alankrit.srivastava256@webkul.com&gt;\"\r\n\r\nRUN apt-get update \\\r\n    &amp;&amp; apt-get -y install apache2 nano mysql-client \\\r\n    &amp;&amp; a2enmod rewrite \\\r\n    &amp;&amp; a2enmod headers \\\r\n    &amp;&amp; export LANG=en_US.UTF-8 \\\r\n    &amp;&amp; apt-get update \\\r\n    &amp;&amp; apt-get install -y software-properties-common \\\r\n    &amp;&amp; apt-get install -y language-pack-en-base \\\r\n    &amp;&amp; LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej\/php \\\r\n    &amp;&amp; apt-get update \\\r\n    &amp;&amp; apt-get -y install php7.1 php7.1-curl php7.1-intl php7.1-gd php7.1-dom php7.1-mcrypt php7.1-iconv php7.1-xsl php7.1-mbstring php7.1-ctype   php7.1-zip php7.1-pdo php7.1-xml php7.1-bz2 php7.1-calendar php7.1-exif php7.1-fileinfo php7.1-json php7.1-mysqli php7.1-mysql php7.1-posix php7.1-tokenizer php7.1-xmlwriter php7.1-xmlreader php7.1-phar php7.1-soap php7.1-mysql php7.1-fpm php7.1-bcmath libapache2-mod-php7.1 \\\r\n    &amp;&amp; sed -i -e\"s\/^memory_limit\\s*=\\s*128M\/memory_limit = 512M\/\" \/etc\/php\/7.1\/apache2\/php.ini \\\r\n    &amp;&amp; rm \/var\/www\/html\/* \\\r\n    &amp;&amp; sed -i \"s\/None\/all\/g\" \/etc\/apache2\/apache2.conf \\\r\n##install supervisor and setup supervisord.conf file\r\n    &amp;&amp; apt-get install -y supervisor \\\r\n    &amp;&amp; mkdir -p \/var\/log\/supervisor\r\nenv APACHE_RUN_USER    www-data\r\nenv APACHE_RUN_GROUP   www-data\r\nenv APACHE_PID_FILE    \/var\/run\/apache2.pid\r\nenv APACHE_RUN_DIR     \/var\/run\/apache2\r\nenv APACHE_LOCK_DIR    \/var\/lock\/apache2\r\nenv APACHE_LOG_DIR     \/var\/log\/apache2\r\nenv LANG               C\r\n\r\nWORKDIR \/var\/www\/html\r\n\r\nCMD [\"\/usr\/bin\/supervisord\"]\r\n<\/pre>\n<p>And at last we have <em>supervisord.conf<\/em> file that supervisor use to run apache2 server and ownership commands. Its contents are shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">[supervisord]\r\nnodaemon=true\r\n\r\n[program:apache2]\r\ncommand=\/bin\/bash -c \"source \/etc\/apache2\/envvars &amp;&amp; exec \/usr\/sbin\/apache2 -DFOREGROUND\"\r\n\r\n[program:user_permission]\r\ncommand=\/bin\/bash -c \"chown -R www-data: \/var\/www\/\"\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Moving on to our <em>database_server directory,\u00a0<\/em>it contains 3 files. <em>Dockerfile<\/em> is shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">FROM ubuntu:16.04\r\n\r\nLABEL maintainer=\"Alankrit Srivastava &lt;alankrit.srivastava256@webkul.com&gt;\"\r\n\r\nARG mysql_password\r\nARG mysql_database\r\nenv MYSQL_ROOT_PASSWORD ${mysql_password}\r\nenv MYSQL_DATABASE ${mysql_database}\r\n\r\nRUN apt-get update \\\r\n&amp;&amp; echo \"mysql-server-5.7 mysql-server\/root_password password ${mysql_password}\" | debconf-set-selections \\\r\n&amp;&amp; echo \"mysql-server-5.7 mysql-server\/root_password_again password ${mysql_password}\" | debconf-set-selections \\\r\n&amp;&amp; DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server-5.7 &amp;&amp; \\\r\n    mkdir -p \/var\/lib\/mysql &amp;&amp; \\\r\n    mkdir -p \/var\/run\/mysqld &amp;&amp; \\\r\n    mkdir -p \/var\/log\/mysql &amp;&amp; \\\r\n    touch \/var\/run\/mysqld\/mysqld.sock &amp;&amp; \\\r\n    touch \/var\/run\/mysqld\/mysqld.pid &amp;&amp; \\\r\n    chown -R mysql:mysql \/var\/lib\/mysql &amp;&amp; \\\r\n    chown -R mysql:mysql \/var\/run\/mysqld &amp;&amp; \\\r\n    chown -R mysql:mysql \/var\/log\/mysql &amp;&amp;\\\r\n    chmod -R 777 \/var\/run\/mysqld\/ \\\r\n    &amp;&amp; sed -i -e\"s\/^bind-address\\s*=\\s*127.0.0.1\/bind-address = 0.0.0.0\/\" \/etc\/mysql\/mysql.conf.d\/mysqld.cnf \\\r\n##install supervisor and setup supervisord.conf file\r\n    &amp;&amp; apt-get install -y supervisor nano \\\r\n    &amp;&amp; mkdir -p \/var\/log\/supervisor \r\nCMD [\"\/usr\/bin\/supervisord\"]<\/pre>\n<p>&nbsp;<\/p>\n<p>So as we have seen in our last blog as well that\u00a0Dockerfile just install packages as it is instructed to do by the commands.<\/p>\n<p>As mentioned earlier consider image as rest package where no services or processes are running. That is why we cannot perform any operation from Dockerfile that requires a particular service to be running.\u00a0<em><strong>As with case of database, we cannot create database from Dockerfile as mysql service is not running. For database and its user creation, we will create a bash script that will run whenever a container will launch, hence creating mentioned database and its user.<\/strong><\/em><\/p>\n<p>We are using \u201cmysql.sh\u201d as the bash script as mentioned in Dockerfile. Bash script \u201cmsyql.sh\u201d resides on our host parallel to Dockerfile.<\/p>\n<p>Contents of <em>mysql.sh<\/em> is shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">#!\/bin\/bash\r\n\r\nset -u\r\nsleep 4\r\ndatabase_connectivity_check=no\r\nvar=1\r\nwhile [ \"$database_connectivity_check\" != \"mysql\" ]; do\r\n\/etc\/init.d\/mysql start\r\nsleep 2\r\ndatabase_connectivity_check=`mysqlshow --user=root --password=$MYSQL_ROOT_PASSWORD | grep -o mysql`\r\nif [ $var -ge 4 ]; then\r\nexit 1\r\nfi\r\nvar=$((var+1))\r\ndone\r\n\r\n\r\ndatabase_availability_check=`mysqlshow --user=root --password=$MYSQL_ROOT_PASSWORD | grep -ow \"$MYSQL_DATABASE\"`\r\n\r\nif [ \"$database_availability_check\" == \"$MYSQL_DATABASE\" ]; then\r\nexit 1\r\nelse\r\nmysql -u root -p$MYSQL_ROOT_PASSWORD -e \"grant all on *.* to 'root'@'%' identified by '$MYSQL_ROOT_PASSWORD';\"\r\nmysql -u root -p$MYSQL_ROOT_PASSWORD -e \"create database $MYSQL_DATABASE;\"\r\nmysql -u root -p$MYSQL_ROOT_PASSWORD -e \"grant all on $MYSQL_DATABASE.* to 'root'@'%' identified by '$MYSQL_ROOT_PASSWORD';\"\r\nsupervisorctl stop database_creation &amp;&amp; supervisorctl remove database_creation\r\necho \"Database $MYSQL_DATABASE created\"\r\nfi\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Apart from mysql.sh and Dockerfile, we are also mapping supervisord.conf file. Its contents are shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">[supervisord]\r\nnodaemon=true\r\n \r\n\r\n[program:mysql]\r\ncommand=\/bin\/bash -c \"touch \/var\/run\/mysqld\/mysqld.sock;touch \/var\/run\/mysqld\/mysqld.pid;chown -R mysql:mysql \/var\/lib\/mysql;chown -R mysql:mysql \/var\/run\/mysqld;chown -R mysql:mysql \/var\/log\/mysql;chmod -R 777 \/var\/run\/mysqld\/;\/etc\/init.d\/mysql restart\"\r\n\r\n[program:database_creation]\r\ncommand=\/bin\/bash -c \"chmod a+x \/etc\/mysql.sh; \/etc\/mysql.sh\"<\/pre>\n<p>&nbsp;<\/p>\n<p>And our last directory is <em>magento2 directory.\u00a0<\/em>In our case we have download Magento 2 latest version from <a href=\"https:\/\/magento.com\/tech-resources\/download\">https:\/\/magento.com\/tech-resources\/download<\/a> and unarchive it in magento2 directory. This directory will be mapped with \/var\/www\/html directory in docker container.<\/p>\n<p>Now, when directory setup is complete, check the ports to be allocated are available. Go to project directory and run the following command to build the image.<\/p>\n<pre class=\"lang:default decode:true\">docker-compose build<\/pre>\n<p>It will create two images. Check the images by running command:<\/p>\n<pre class=\"lang:default decode:true\">docker images<\/pre>\n<p>Now to run the containers as a part of single project being as mentioned in docker-compose.yml file, run the command:<\/p>\n<pre class=\"lang:default decode:true\">docker-compose up -d<\/pre>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-200119.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3350\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-200119.png\" alt=\"\" width=\"909\" height=\"94\" \/><\/a><\/p>\n<p>Your containers will get running. To list running containers under docker-compose, run command:<\/p>\n<pre class=\"lang:default decode:true\">docker-compose ps<\/pre>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-185438.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3334\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-185438.png\" alt=\"\" width=\"692\" height=\"74\" \/><\/a><\/p>\n<p>Your database credentials are mentioned in mysql.sh file. To get database user password, you can either enter the running container and check the \/var\/log\/check.log file as:<\/p>\n<pre class=\"lang:default decode:true\">docker exec -ti mysql bash\r\n\r\ncat \/var\/log\/check.log<\/pre>\n<p>Or, you can get it directly from host as:<\/p>\n<pre class=\"lang:default decode:true\">docker exec -i mysql cat \/var\/log\/check.log<\/pre>\n<p>Now, your server setup is all ready, hit your domain name or IP to install Magento 2.<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150440.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3335\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150440.png\" alt=\"\" width=\"774\" height=\"385\" \/><\/a><\/p>\n<p>Now begin with setting up Magento, perform readiness check,<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150500.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3336\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150500.png\" alt=\"\" width=\"1284\" height=\"647\" \/><\/a><\/p>\n<p>Now, mention \u00a0database details as we have mentioned in mysql.sh file.<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150648.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3337\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150648.png\" alt=\"\" width=\"1259\" height=\"641\" \/><\/a>Now, mention your admin panel details.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3339\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150813.png\" alt=\"\" width=\"1288\" height=\"648\" \/><\/p>\n<p>After this, we are set to install our Magento 2, click on install button to proceed.<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150828-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3340\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/Screenshot-from-2017-09-06-150828-1.png\" alt=\"\" width=\"1076\" height=\"436\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>So far we have discussed how to setup Magento 2 using docker-compose on multiple docker container architecture. Also refer to git repository <a href=\"https:\/\/github.com\/webkul\/magento2-docker-compose\">https:\/\/github.com\/webkul\/magento2-docker-compose<\/a>. In our next blog we will setup Magento 2 with Varnish cache on Docker architecture.<\/p>\n<p>If you have any issues, contact us at <a href=\"mailto:support@webkul.com\">support@webkul.com<\/a> or raise ticket at <a href=\"https:\/\/webkul.uvdesk.com\/\" rel=\"nofollow\">https:\/\/webkul.uvdesk.com\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our last blog, we had discussed briefly about Docker architecture and its three components. <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":7,"featured_media":3343,"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>Magento 2 With Docker-Compose - Cloudkul<\/title>\n<meta name=\"description\" content=\"With the help of docker-compose we can define containers to be built, their configuration, links, volumes, ports etc in a single file and it gets launched by a single command. We can add multiple servers and services just by adding them to docker-compose configuration file. Magento 2 files will be placed on our host. As it is a good practice to keep application files on host so that it will not be lost if containers or images get accidentally removed. These magento files will be mapped from host to running docker container.\" \/>\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\/magento-2-docker-compose\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento 2 With Docker-Compose - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"With the help of docker-compose we can define containers to be built, their configuration, links, volumes, ports etc in a single file and it gets launched by a single command. We can add multiple servers and services just by adding them to docker-compose configuration file. Magento 2 files will be placed on our host. As it is a good practice to keep application files on host so that it will not be lost if containers or images get accidentally removed. These magento files will be mapped from host to running docker container.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-06T14:11:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-07-17T09:25:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/download-1.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=\"Alankrit Srivastava\" \/>\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\/magento-2-docker-compose\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/\",\"name\":\"Magento 2 With Docker-Compose - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2017-09-06T14:11:20+00:00\",\"dateModified\":\"2018-07-17T09:25:08+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/fc06bfd7f18d9a606dd94062d205af16\"},\"description\":\"With the help of docker-compose we can define containers to be built, their configuration, links, volumes, ports etc in a single file and it gets launched by a single command. We can add multiple servers and services just by adding them to docker-compose configuration file. Magento 2 files will be placed on our host. As it is a good practice to keep application files on host so that it will not be lost if containers or images get accidentally removed. These magento files will be mapped from host to running docker container.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento 2 With Docker-Compose\"}]},{\"@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\/fc06bfd7f18d9a606dd94062d205af16\",\"name\":\"Alankrit Srivastava\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/955c3dda2678272c436c5153832e401f?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/955c3dda2678272c436c5153832e401f?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Alankrit Srivastava\"},\"description\":\"DevOps Manager at Webkul Software Privated Limited\",\"sameAs\":[\"http:\/\/cloudkul.com\"],\"url\":\"https:\/\/cloudkul.com\/blog\/author\/alankrit-srivastava256\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento 2 With Docker-Compose - Cloudkul","description":"With the help of docker-compose we can define containers to be built, their configuration, links, volumes, ports etc in a single file and it gets launched by a single command. We can add multiple servers and services just by adding them to docker-compose configuration file. Magento 2 files will be placed on our host. As it is a good practice to keep application files on host so that it will not be lost if containers or images get accidentally removed. These magento files will be mapped from host to running docker container.","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\/magento-2-docker-compose\/","og_locale":"en_US","og_type":"article","og_title":"Magento 2 With Docker-Compose - Cloudkul","og_description":"With the help of docker-compose we can define containers to be built, their configuration, links, volumes, ports etc in a single file and it gets launched by a single command. We can add multiple servers and services just by adding them to docker-compose configuration file. Magento 2 files will be placed on our host. As it is a good practice to keep application files on host so that it will not be lost if containers or images get accidentally removed. These magento files will be mapped from host to running docker container.","og_url":"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/","og_site_name":"Cloudkul","article_published_time":"2017-09-06T14:11:20+00:00","article_modified_time":"2018-07-17T09:25:08+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2017\/09\/download-1.png","type":"image\/png"}],"author":"Alankrit Srivastava","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/","url":"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/","name":"Magento 2 With Docker-Compose - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2017-09-06T14:11:20+00:00","dateModified":"2018-07-17T09:25:08+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/fc06bfd7f18d9a606dd94062d205af16"},"description":"With the help of docker-compose we can define containers to be built, their configuration, links, volumes, ports etc in a single file and it gets launched by a single command. We can add multiple servers and services just by adding them to docker-compose configuration file. Magento 2 files will be placed on our host. As it is a good practice to keep application files on host so that it will not be lost if containers or images get accidentally removed. These magento files will be mapped from host to running docker container.","breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/magento-2-docker-compose\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento 2 With Docker-Compose"}]},{"@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\/fc06bfd7f18d9a606dd94062d205af16","name":"Alankrit Srivastava","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/955c3dda2678272c436c5153832e401f?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/955c3dda2678272c436c5153832e401f?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Alankrit Srivastava"},"description":"DevOps Manager at Webkul Software Privated Limited","sameAs":["http:\/\/cloudkul.com"],"url":"https:\/\/cloudkul.com\/blog\/author\/alankrit-srivastava256\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/3313"}],"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\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=3313"}],"version-history":[{"count":31,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/3313\/revisions"}],"predecessor-version":[{"id":3736,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/3313\/revisions\/3736"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/3343"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=3313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=3313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=3313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}