{"id":92188,"date":"2023-11-22T06:00:47","date_gmt":"2023-11-22T11:30:47","guid":{"rendered":"https:\/\/www.whizlabs.com\/blog\/?p=92188"},"modified":"2023-11-23T00:36:17","modified_gmt":"2023-11-23T06:06:17","slug":"setup-three-tier-application-docker","status":"publish","type":"post","link":"https:\/\/www.whizlabs.com\/blog\/setup-three-tier-application-docker\/","title":{"rendered":"Steps to Setup Three-Tier Application with Docker Containers"},"content":{"rendered":"<p><span style=\"font-size: 16px; font-weight: 400;\">In today&#8217;s world of dynamic web applications, setting up a robust and scalable architecture is a top priority for developers. A three-tier architecture, consisting of presentation, application logic, and data storage layers.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Pairing this architecture with <\/span><a href=\"https:\/\/www.whizlabs.com\/docker-certified-associate\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Docker containers<\/span><\/a><span style=\"font-weight: 400;\"> offers a flexible, efficient, and reliable solution for deploying web applications.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this blog, we will walk you through the step-by-step process of setting up a <strong>three-tier application<\/strong> using Docker containers.<\/span><\/p>\n<p><em><span style=\"font-weight: 400;\">Let\u2019s dive in!<\/span><\/em><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ea7e02;color:#ea7e02\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ea7e02;color:#ea7e02\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.whizlabs.com\/blog\/setup-three-tier-application-docker\/#What_is_a_Three-Tier_Application_with_Docker_Containers\" >What is a Three-Tier Application with Docker Containers?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.whizlabs.com\/blog\/setup-three-tier-application-docker\/#What_is_Docker_Containers\" >What is Docker Containers?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.whizlabs.com\/blog\/setup-three-tier-application-docker\/#Prerequisites\" >Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.whizlabs.com\/blog\/setup-three-tier-application-docker\/#Steps_to_Setup_Three-tier_Application_with_Docker_Containers\" >Steps to Setup Three-tier Application with Docker Containers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.whizlabs.com\/blog\/setup-three-tier-application-docker\/#FAQs\" >FAQs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.whizlabs.com\/blog\/setup-three-tier-application-docker\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"What_is_a_Three-Tier_Application_with_Docker_Containers\"><\/span><strong>What is a Three-Tier Application with Docker Containers?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">A <\/span><a href=\"https:\/\/cloud.google.com\/solutions\/three-tier-web-app?hl=en#overview-section\" target=\"_blank\" rel=\"nofollow noopener\"><span style=\"font-weight: 400;\">three-tier application<\/span><\/a><span style=\"font-weight: 400;\"> is a commonly employed architectural design for developing and deploying web applications. It organizes the application into three distinct and logical layers: presentation, application logic, and data storage.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Each of these layers has a unique role, and when integrated with Docker containers, it provides a versatile and scalable approach to creating and overseeing web applications.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here are some aspects of Setting Up a Three-Tier Application with Docker Containers:<\/span><\/p>\n<p><b>Presentation Tier<\/b><\/p>\n<p><span style=\"font-weight: 400;\">This tier will be involved in user interface design and interaction was made with the end users. It comprises web servers such as\u00a0 Nginx or Apache and it includes programming languages such as\u00a0 <strong>HTML, CSS, and client-side scripts.<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Dockers in the presentation layer are configured to expose certain ports and routes to manage user requests.<\/span><\/p>\n<p><b>Application Logic Tier<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The application logic tier includes web application core functionalities. It takes care of data processing, user request handling, interaction management between the data tiers, and presentation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In the application logic tier, containers execute the application code, often using web application frameworks like <strong>Django, Ruby on Rails, or Spring Boot<\/strong>. These containers need to be set up to establish connections with the presentation tier through clearly defined APIs or endpoints.<\/span><\/p>\n<p><b>Data Storage Tier<\/b><\/p>\n<p><span style=\"font-weight: 400;\">As for the data storage tier, its primary role is to handle data management and storage, typically involving databases. Containers in this tier can operate database management systems such as <strong>MySQL, PostgreSQL, or NoSQL<\/strong> databases like MongoDB.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It&#8217;s crucial to ensure that the containers in this tier are configured securely to persist data and allow secure access to the application logic tier.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_Docker_Containers\"><\/span><strong>What is Docker Containers?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">A container is a standardized unit of software that bundles together not only the application code but also all the essential dependencies. This packaging allows an application to run consistently and reliably across various computing environments.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0A <\/span><a href=\"https:\/\/www.whizlabs.com\/blog\/docker-architecture-in-detail\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Docker container<\/span><\/a><span style=\"font-weight: 400;\"> image, in particular, is a compact, self-sufficient package containing everything necessary to execute an application: <strong>the code, runtime, system tools, system libraries, and configurations.<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\">When you run a Docker container image on the Docker Engine, it transforms into a live container. This applies to both Linux and Windows-based applications. Containerized software guarantees consistent behavior, irrespective of the underlying infrastructure. Containers effectively shield software from variations in its environment, ensuring that it performs consistently, whether in a development or staging environment, or any other setting.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Three-tier application benefits with Docker Containers:<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92193\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Three-tier-application-benefits-with-Docker-Containers.webp\" alt=\"docker containers benefits\" width=\"2292\" height=\"2084\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Three-tier-application-benefits-with-Docker-Containers.webp 2292w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Three-tier-application-benefits-with-Docker-Containers-300x273.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Three-tier-application-benefits-with-Docker-Containers-1024x931.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Three-tier-application-benefits-with-Docker-Containers-768x698.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Three-tier-application-benefits-with-Docker-Containers-1536x1397.webp 1536w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Three-tier-application-benefits-with-Docker-Containers-2048x1862.webp 2048w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Three-tier-application-benefits-with-Docker-Containers-150x136.webp 150w\" sizes=\"(max-width: 2292px) 100vw, 2292px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Modularity: <\/b><span style=\"font-weight: 400;\">Docker containers encapsulate application components and dependencies, making it easy to manage and update each tier independently.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Consistency: <\/b><span style=\"font-weight: 400;\">Docker ensures that your application runs consistently across different environments, reducing compatibility issues and improving reliability.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Scalability:<\/b><span style=\"font-weight: 400;\"> Docker containers can be easily scaled up or down, making it simpler to accommodate changes in user demand and traffic.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Efficiency:<\/b><span style=\"font-weight: 400;\"> Docker&#8217;s lightweight nature and rapid deployment reduce resource wastage, making the most of your infrastructure.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Isolation: <\/b><span style=\"font-weight: 400;\">Containers isolate application components, enhancing security and minimizing interference between tiers.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Portability: <\/b><span style=\"font-weight: 400;\">Docker containers can run on various platforms and cloud providers, offering flexibility and portability.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Automation: <\/b><span style=\"font-weight: 400;\">Docker enables automation of deployment processes, speeding up development and reducing human errors.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Testing and Debugging: <\/b><span style=\"font-weight: 400;\">Containers are ideal for testing and debugging, facilitating quicker development cycles.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Maintainability:<\/b><span style=\"font-weight: 400;\"> Containerized applications are easier to maintain, update, and troubleshoot.<\/span><\/li>\n<\/ul>\n<blockquote><p>Also Read : <a href=\"https:\/\/www.whizlabs.com\/blog\/what-is-docker\/\" target=\"_blank\" rel=\"noopener\">What is Docker?<\/a><\/p><\/blockquote>\n<h3><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span><strong>Prerequisites<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Before you begin with this tutorial, make sure you have the following prerequisites in place:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>An active Internet connection:<\/strong> You&#8217;ll need a stable and active Internet connection to access the required resources and documentation during the tutorial.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Docker installation:<\/strong> Ensure that you have Docker installed on your computer. Docker is a critical tool for creating and managing containers, which is essential for following this tutorial. You can follow the instructions below to install Docker.<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Steps_to_Setup_Three-tier_Application_with_Docker_Containers\"><\/span><strong>Steps to Setup Three-tier Application with Docker Containers<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">To set up a <\/span><a href=\"https:\/\/www.whizlabs.com\/labs\/setup-three-tier-application-with-docker-containers\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Three-tier Application with Docker Containers<\/span><\/a><span style=\"font-weight: 400;\"> successfully, follow these steps:<\/span><\/p>\n<p><b>Task 1: Sign in to the AWS Management Console<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click the &#8220;Open Console&#8221; button to access the AWS Management Console.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">On the AWS sign-in page, leave the Account ID as default. Copy your User Name and Password from the Lab Console to the IAM Username and Password in the AWS Console, then click &#8220;Sign in.&#8221;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Set the default AWS Region to &#8220;US East (N. Virginia) us-east-1.&#8221;<\/span><\/li>\n<\/ul>\n<p><b>Task 2: Launch an EC2 Instance with Desired Specifications<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ensure you are in the &#8220;US East (N. Virginia) us-east-1&#8221; Region.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Navigate to EC2 by clicking &#8220;Services&#8221; and selecting &#8220;EC2&#8221; in the &#8220;Compute&#8221; section.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click &#8220;Instances&#8221; on the left panel, then click &#8220;Launch Instances.&#8221;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Name the instance as &#8220;MyEC2Server.&#8221;<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92196 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/name-and-tags.webp\" alt=\"name-and-tags\" width=\"590\" height=\"142\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/name-and-tags.webp 590w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/name-and-tags-300x72.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/name-and-tags-150x36.webp 150w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Search for the &#8220;Amazon Linux 2 AMI&#8221; and select it.<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92197 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Amazon-Linux.webp\" alt=\"Amazon-Linux\" width=\"564\" height=\"258\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Amazon-Linux.webp 564w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Amazon-Linux-300x137.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Amazon-Linux-150x69.webp 150w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Choose &#8220;t2.micro&#8221; as the instance type.<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92198 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Instance-Type.webp\" alt=\"Instance-Type\" width=\"617\" height=\"184\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Instance-Type.webp 617w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Instance-Type-300x89.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Instance-Type-150x45.webp 150w\" sizes=\"(max-width: 617px) 100vw, 617px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Create a new key pair with the name &#8220;WhizKey,&#8221; type &#8220;RSA,&#8221; and file format &#8220;.pem.&#8221;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In Network Settings, enable &#8220;Auto-assign public IP.&#8221;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Create a security group named &#8220;MyEC2Server_SG&#8221; and describe it as a Security Group to allow traffic to the EC2 instance.<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92199 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Auto-assign-EC2.webp\" alt=\"Auto-assign-EC2\" width=\"604\" height=\"303\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Auto-assign-EC2.webp 604w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Auto-assign-EC2-300x150.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Auto-assign-EC2-150x75.webp 150w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Add security group rules for SSH and HTTP.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Proceed to launch the instance by clicking &#8220;Launch Instance.&#8221;<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92200 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Inbound-.webp\" alt=\"inbound security\" width=\"610\" height=\"496\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Inbound-.webp 610w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Inbound--300x244.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Inbound--150x122.webp 150w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Wait for the instance to become &#8220;Running&#8221; with a health check status of &#8220;2\/2 checks passed.&#8221;<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92201 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/2-on-2-checks-passed.webp\" alt=\"2-on-2-checks-passed\" width=\"608\" height=\"118\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/2-on-2-checks-passed.webp 608w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/2-on-2-checks-passed-300x58.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/2-on-2-checks-passed-150x29.webp 150w\" sizes=\"(max-width: 608px) 100vw, 608px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Copy the public IPv4 address for later use.<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92202 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Instance-ID-Details.webp\" alt=\"\" width=\"628\" height=\"193\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Instance-ID-Details.webp 628w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Instance-ID-Details-300x92.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Instance-ID-Details-150x46.webp 150w\" sizes=\"(max-width: 628px) 100vw, 628px\" \/><\/p>\n<p><strong>Task 3: SSH into EC2 Instance Using the Key Pair<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select your EC2 instance (&#8220;MyEC2Server&#8221;) and click &#8220;Connect.&#8221;<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92203 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/EC2-Instance-Connect.webp\" alt=\"EC2-Instance-Connect\" width=\"610\" height=\"190\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/EC2-Instance-Connect.webp 610w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/EC2-Instance-Connect-300x93.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/EC2-Instance-Connect-150x47.webp 150w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Choose &#8220;EC2 Instance Connect&#8221; and click &#8220;Connect.&#8221;<\/span><\/li>\n<\/ul>\n<p><b>Task 4: Install an Apache Server on the Instance<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Switch to the root user: sudo su<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Update the system: yum -y update<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Install the Apache web server: yum install docker -y<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Start the Docker service: systemctl start docker<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Enable Docker to start on boot: systemctl enable docker<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Check the Docker service status: systemctl status docker<\/span><\/li>\n<\/ul>\n<p><b>Task 5: Create Docker Containers for Each Tier<\/b><\/p>\n<p><b>Presentation Tier<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Create a Docker container for presentation tier using the Nginx image with the following command:<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"size-full wp-image-92204 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Presentation-Tier.webp\" alt=\"Presentation-Tier\" width=\"619\" height=\"94\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Presentation-Tier.webp 619w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Presentation-Tier-300x46.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Presentation-Tier-150x23.webp 150w\" sizes=\"(max-width: 619px) 100vw, 619px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">docker run -d &#8211;name presentation-tier -p 80:80 nginx<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">docker run initiates a new container.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">-d runs the container in detached mode.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">&#8211;name presentation-tier assigns a name to the container.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">-p 80:80 maps port 80 from the host to port 80 in the container.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">&#8220;nginx&#8221; specifies the image to use.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><b>Application Logic Tier<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">You can create Docker containers for the application logic tier using the application image<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92205\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Application-Logic-Tier.webp\" alt=\"Application-Logic-Tier\" width=\"636\" height=\"86\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Application-Logic-Tier.webp 636w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Application-Logic-Tier-300x41.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Application-Logic-Tier-150x20.webp 150w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-size: 16px; font-weight: 400;\">docker run -d &#8211;name app-logic-tier-1 &lt;app-image&gt;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">We can simply use same -d and &#8211;name options as we did in presentation tier.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Replace &lt;app-image&gt; with the application&#8217;s Docker image name. For example, use &#8220;httpd.&#8221;<\/span><\/li>\n<\/ul>\n<p>Note: You can create multiple instances of your application logic containers as needed.<\/p>\n<p><b>Data Storage Tier<\/b><\/p>\n<p><span style=\"font-weight: 400;\">To create Docker containers for the data storage tier, like using a MySQL image, follow these steps:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Run the container in detached mode with a designated name. For example:<\/span><\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-92206 aligncenter\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/sql-designation-.webp\" alt=\"data storage tier\" width=\"650\" height=\"270\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/sql-designation-.webp 650w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/sql-designation--300x125.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/sql-designation--150x62.webp 150w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Utilize the -e option to specify environment variables, including important settings like the MySQL root password.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">These commands will help you create Docker containers for different tiers of your application, including the presentation tier, application logic tier, and data storage tier. Make sure to replace &lt;app-image&gt; with your actual application image name.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To enhance this setup, you can consider implementing the following improvements using Docker:<\/span><\/p>\n<p><b>Scaling and Load Balancing<\/b><\/p>\n<p><span style=\"font-weight: 400;\">To efficiently manage container scaling and load balancing, you can utilize Docker Swarm. Start by initializing Docker Swarm with the command docker swarm init.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Create a service for the application logic tier and specify the desired number of replicas using the command docker service create.<\/span><\/p>\n<p><b>Security and Isolation\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">You can ensure that each tier is securely isolated by configuring Docker network settings to restrict container communication and enhance overall security.<\/span><\/p>\n<p><b>Monitoring and Logging<\/b><\/p>\n<p><span style=\"font-weight: 400;\">For effective monitoring and logging, you can implement external tools like Prometheus and the ELK Stack. These tools provide detailed insights into your containerized applications, helping you manage and troubleshoot them effectively.<\/span><\/p>\n<p><b>Continuous Integration and Continuous Deployment (CI\/CD)<\/b><\/p>\n<p><span style=\"font-weight: 400;\">To streamline your development process, establish a CI\/CD pipeline. This pipeline automates tasks such as building, testing, and deploying updates to your containerized applications, making your development workflow more efficient and consistent.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"FAQs\"><\/span><strong>FAQs<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><b>Can we run multiple applications in a single container?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Yes, technically, you can run multiple applications within a single Docker container. However, it&#8217;s generally not recommended to do so. Docker containers are designed to be lightweight, isolated environments that typically run a single process or application. This follows the best practice of &#8220;one process per container,&#8221; which helps maintain simplicity, manageability, and scalability in containerized applications.<\/span><\/p>\n<p><b>What are the benefits of Docker containers?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The core benefits of Docker such as speed, consistency, density, and portability.<\/span><\/p>\n<p><b>What is Docker?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Docker is an open platform designed for developing, shipping, and running applications. It provides a way to separate your applications from the underlying infrastructure, allowing you to deliver software rapidly and efficiently.<\/span><\/p>\n<p><b>What is the docker containers list?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">To list the Docker containers, the commands such as \u201cdocker ps\u201d or \u201cdocker container ls\u201d can be used. It provides a variety of ways to list and filter containers on the Docker engine.\u00a0<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Hope you have understood how to set up a three-tier application with the <strong>docker container tutorial<\/strong>. By leveraging the power of Docker containers, we can easily build and manage the <strong>deployment of this architecture.<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\">We also explored the docker containers meaning, concepts, and detailed information about the three-tier application.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To further experience docker in real-time settings, explore our <\/span><a href=\"https:\/\/www.whizlabs.com\/labs\/library\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">hands-on labs<\/span><\/a><span style=\"font-weight: 400;\"> and <\/span><a href=\"https:\/\/www.whizlabs.com\/labs\/sandbox\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">sandboxes<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In today&#8217;s world of dynamic web applications, setting up a robust and scalable architecture is a top priority for developers. A three-tier architecture, consisting of presentation, application logic, and data storage layers. Pairing this architecture with Docker containers offers a flexible, efficient, and reliable solution for deploying web applications. In this blog, we will walk you through the step-by-step process of setting up a three-tier application using Docker containers. Let\u2019s dive in! What is a Three-Tier Application with Docker Containers? A three-tier application is a commonly employed architectural design for developing and deploying web applications. It organizes the application into [&hellip;]<\/p>\n","protected":false},"author":386,"featured_media":92192,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[10,1862],"tags":[2449],"class_list":["post-92188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-computing-certifications","category-devops","tag-containers-docker"],"uagb_featured_image_src":{"full":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI.webp",1280,720,false],"thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI-150x150.webp",150,150,true],"medium":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI-300x169.webp",300,169,true],"medium_large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI-768x432.webp",768,432,true],"large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI-1024x576.webp",1024,576,true],"1536x1536":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI.webp",1280,720,false],"2048x2048":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI.webp",1280,720,false],"profile_24":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI.webp",24,14,false],"profile_48":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI.webp",48,27,false],"profile_96":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI.webp",96,54,false],"profile_150":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI.webp",150,84,false],"profile_300":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI.webp",300,169,false],"tptn_thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI-250x250.webp",250,250,true],"web-stories-poster-portrait":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI-640x720.webp",640,720,true],"web-stories-publisher-logo":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/11\/Steps-to-Setup-three-tier-application-with-Docker-Containers-FI-150x84.webp",150,84,true]},"uagb_author_info":{"display_name":"Basant Singh","author_link":"https:\/\/www.whizlabs.com\/blog\/author\/basant-singh\/"},"uagb_comment_info":10,"uagb_excerpt":"In today&#8217;s world of dynamic web applications, setting up a robust and scalable architecture is a top priority for developers. A three-tier architecture, consisting of presentation, application logic, and data storage layers. Pairing this architecture with Docker containers offers a flexible, efficient, and reliable solution for deploying web applications. In this blog, we will walk&hellip;","_links":{"self":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/92188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/users\/386"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/comments?post=92188"}],"version-history":[{"count":11,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/92188\/revisions"}],"predecessor-version":[{"id":92234,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/92188\/revisions\/92234"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media\/92192"}],"wp:attachment":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media?parent=92188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/categories?post=92188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/tags?post=92188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}