{"id":215,"date":"2021-10-27T14:25:21","date_gmt":"2021-10-27T14:25:21","guid":{"rendered":"http:\/\/18.141.20.153\/?p=215"},"modified":"2025-08-22T08:07:25","modified_gmt":"2025-08-22T08:07:25","slug":"how-to-install-and-run-docker-containers-on-amazon-ec2-instance","status":"publish","type":"post","link":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/","title":{"rendered":"How to install and run Docker Containers on Amazon EC2 Instance?"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/GSxJlWdBN4zGgqjMJOrSQzJPCc0XYvXa01JLzWejgQ8l0twXZW_G468595FfOp9Z9TaIf7F4jQKqq1taERFNENL2H7B3gbbLZ2NvBzXz6zs2mq7_UNCbazZlVsUnThGRMCYzZb0\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">While running Docker on AWS, developers and admins can build, ship, and run highly reliable distributed applications at any scale.&nbsp;&nbsp;In this blog, we will demonstrate how to install, build and run docker containers on Amazon EC2 instances.<\/p>\n\n\n\n<p>Refer to Part 1 of the blog here: <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-install-and-run-docker-container-on-amazon-ec2-instance-part-1\/\">How To Install And Run Docker Container On Amazon EC2 Instance (Part 1)?<\/a><\/p>\n\n\n\n<h2>What is Docker?<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/3PMxnlSP47YhlE30GM-ICMpV4uDJqVXPtVO4UAwvO8waOzWuSEEyFF31cXdNIiGMa9o4RJFxbwMDXLk76HuuPnRw82OlVP3WR6iU0IyTwzRRmn3pxL-_iAdKR_T5bLMpdQ-H2ks\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\"><a href=\"https:\/\/www.docker.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Docker<\/a> provides the tools for building, running, testing, and deploying distributed applications that are based on Linux containers. It has the ability to package and run applications in a loosely isolated environment called containers. You can run many containers simultaneously on a given host. They are lightweight and contain everything needed to run the applications, so no need to depend on what is currently being installed on the host. While running Docker on AWS, developers, and admins can build, ship, and run highly reliable distributed applications at any scale.&nbsp;&nbsp;<\/p>\n\n\n\n<h2>What is Amazon EC2?<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/0t-HChcW0bbF6q6HvTpJYK73bC77MI7wfdwXnbEr4c3Rk-KkaSGhRvEqPlpqy0EtF_NA-fDaYnRaYUxetEtEyIv_EgKFBPZQ8Y9foki6bbe5WzOjVH_YURdHsv7Hmss-dj1QIT4\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Amazon Elastic Computing Cloud (Amazon EC2) is a cloud computing service that offers safe, scalable computing power. It&#8217;s intended to make web-scale cloud computing more accessible to programmers. The easy web service interface of Amazon EC2 allows you to quickly obtain and configure capacity. It gives you complete control over your computing resources and allows you to run on Amazon&#8217;s tried-and-true computing infrastructure.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Scenario<\/strong>: In this blog, we will demonstrate to launch an EC2 instance, we will create a Dockerfile to run the Ubuntu image, install packages for the Apache web server, and display \u201cHello World!&#8221; content to the web server&#8217;s index root.<\/p>\n\n\n\n<h2>Hands-on<\/h2>\n\n\n\n<p><strong>Steps to be followed:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<ul type=\"1\"><li>Create and launch the EC2 instance<\/li><li>Install Docker on an Amazon EC2 instance<\/li><li>Create, build Dockerfile, and run the Docker Container<\/li><\/ul>\n<\/div><\/div>\n\n\n\n<p><strong>Create and launch the EC2 instance<\/strong><\/p>\n\n\n\n<p>Navigate to the EC2 dashboard, and click on Launch Instances.<\/p>\n\n\n\n<p><br><img src=\"https:\/\/lh5.googleusercontent.com\/-YxIVQkA7qthmi3EeJBiQd7Luj8WQ6D10AkCSTkXPWEpzA7eg2rbIuWb1PEgHTcIrpYhhePh_Z6tR4XMQSBoqtW4S_YOlW3R9d9FHvsW5orM0SeFhfRgA0oj2lBbHf2ZRY1Npy8\" style=\"width: undefinedpx;\"><\/p>\n\n\n\n<p>Choose AMI image&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/SnaW5r_auOE2xbHR0Ya_i1v3Q-Yn9grlvG9Ot-omZGEroZfw2AAjAQqUjM847W8AQHNbnm5qQQg1HHscPed51q8YQm4-wgdWb0f33d42d8kO7LEqMOPgtvDUe42DBcZ4a1w022c\" alt=\"\"\/><\/figure>\n\n\n\n<p>Choose instance type and configure storage, VPC details<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/TxCr3mLddSBTpDnQBRZlY08j_T1BUXSq92N1aEV0TNx3PcVZJWGI6PV-Jx3NgxdD0ARoKc2n1uMWoFNvjcAXn4j5iLSpf1nA3NEhCEKgVDC2I9g4N_58Yd1AzmIdaChGlL1iJyo\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p>Give appropriate tags to the instance<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/oMWW4AGi6AqlxOkW31VDoZOdsLS3GDf3jDtZmoYbemLqyiWiKwpsTNIKNxQZD9QFVUnMaYayGrztm3iADhVNjz9FJXZrt7NTWFLZdIzenDFktHHqsDoQIv5wOUSsKHCOv5dbHyE\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p>Configure security group for the instance<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/svBvOUjauvsu9EWi0p_SjVUJ-r3gJHjryWqUDRx14sqe19-1baQOSp5mcisEQ0nywYhwoJ6Rg9k_9NuEyw2WQQ-8H9TqdCvl7DzcK4ARI2nbuUZ7ooaVaToCPvo5KHI9a4hNoKQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>Review and launch instance&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/2bEjeqE9ftOAUwy4asRhsBhyp1WGeQr3Kw0uLsyHuKH6lC1wZSaNsHw3z03UNL247b_53B3PmH51VObE6yGXI__4T479aw3Z4OG8phhHy1oGMkmhAyJeD25UA6xLns_7KRhVorg\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/wiEf8yb54lFHz3llCDE8kAjmgL1GiFb48zSXt3qDSbyHzDObPgcwSOh4UJi5DI5dwseDEvjkCj8NniM1pDyhnwB2udNKNXmvqTD5gUi8fR0enmHJ34qTpgRyWWe3KemtVRij-ds\" alt=\"\"\/><\/figure>\n\n\n\n<p>Connect to your instance<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/EAex5roCxfZz2Y1uVyeLTNI2QDt6Dru0FqLKZTsUi3l2DZIRzyM7T1TxZdXOiiEm-zCSLYRArZTfyjTCPI4l6V2PRoCWDq-93Wy-pnRyfiCYn-cEesRugidUiB-qZhNxVa-aEb8\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p><strong>Install Docker on an Amazon EC2 instance<\/strong><\/p>\n\n\n\n<p>Update the installed packages and package cache on your instance.<\/p>\n\n\n\n<p><code>sudo yum update -y<\/code><\/p>\n\n\n\n<p>Install the most recent Docker Engine package.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/sxFg8ZPpVVDTllX_rRmIFHsiJPikdAFQNZ019RfF9YEYPMoRMrzhmr-NulR3SbB3SkJjm8-I_mi9WHzeOULebDI0-6sThqsnlynrc2OF2LYRq9953IdXYr3Ch_TTP12I0Z5eViE\" alt=\"\"\/><\/figure>\n\n\n\n<p>Start the Docker service.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/j738GPMZ_uT-jqMvYMGIoKut4FqbpdwsvFWMQnL2YehCo20LfXaerEUpUGPWxan1G4ChtQjLSQx2QVOc1f_xxLGquI8ZHPcKqeqqvm-rX4SC9rC5jGZrzb0Va1k9nmKWVVTka0c\" alt=\"\"\/><\/figure>\n\n\n\n<p>Add the ec2-user to the docker group so you can execute Docker commands without using sudo<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/9RXNZn2V0ixDzyVxQm4jqec3iXrpCH7jE5WDrkzYtJzz16VgtPrUB_xIyTSR6x2eQxCMt_hHpbGzCGxbBPctUXXN_hrzEKdjyfs-Xes1EhKUP7C3Ja2ou0zNKMEJfGsO5eYHjrE\" alt=\"\"\/><\/figure>\n\n\n\n<p>Log out and log back in again to pick up the new docker group permissions. You can accomplish this by closing your current SSH terminal window and reconnecting to your instance in a new one. Your new SSH session will have the appropriate docker group permissions.<\/p>\n\n\n\n<p>Verify that the ec2-user can run Docker commands without sudo.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/8UweIh_z8q7iPLVqJ7OkJpWaYXCU_qhkAVaLv1QEC4AnfzrecU5RUw0ouCcXlaU0tSEtFG-yUc7_HN5Njd0fKQ3C1p9aPjW3kx_BDHOeJjy2MKeuII3pPBfHKvylKGeLpNnCCpU\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p><strong>Create, build Dockerfile, and run the Docker Container<\/strong><\/p>\n\n\n\n<p>Create a file called Dockerfile. A Dockerfile is a manifest that describes the base image to use for your Docker image and what you want to be installed and running on it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/AEltxsfG2HKX6ly_PU5O61kGbWoVNoapGAgKYaZkUwEPzzHsGv9_NKwdaAeUV6W7cVrXPTTAjGHwbAQAQOOfsz_tBPB8Lelimh4Ccb9IaNjCHhOEK-hxT0ej2aRof2zTQYo_HmI\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p>Edit the Dockerfile you just created and add the following content.<\/p>\n\n\n\n<p><img src=\"https:\/\/lh5.googleusercontent.com\/ktxso1mxvdi6r1Ul9STW31USWOZZ1koaFDnmNhsWJRVI9MA-DTaCHeNuovM-gTwd6mKUIw6x7NtMPNsYJPhJrNuYBZ8dDjQZeMmjQ3fcL9VWhJp_pwsbrSr-5vfPLhKgLhSzzt8\" style=\"width: undefinedpx;\"><\/p>\n\n\n\n<p>Build the Docker image from your Dockerfile.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/At3okJhzde4GUc6lnxJb_5CzkswdcKUia4b7DSWMAK8T0WVPlr9MWW25eNQXnk-Eh584V6OVmjpZJ5kmuSc4ihys-Tc6o5hMTyOAIN67cDBw42wkb8THg08Qw3VEMQW90QE4_LY\" alt=\"How to install and run Docker Containers on Amazon EC2 Instance?\"\/><\/figure>\n\n\n\n<p>Run docker images to verify that the image was created correctly.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/ow59OIFn3qGcdEt_hGaoAt-Kt5-iJJX5fOG9fMfO2sZUvNYixdZuTceKJkCayO2Xug-q8qAjtOZxgruK6B6PX1M1O8GqNjGP4Ahox9ZiYGaAy99ScgY4oEkhX7wFu49-LMgAST4\" alt=\"\"\/><\/figure>\n\n\n\n<p>Run the newly built image. The -p 80:80 option maps the exposed port 80 on the container to port 80 on the host system.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/8NUxuz-5so8SZZvE8L-z1P3hHmOIhkrh8oQI89hc7ysbIWs2PIO3SOeruVrmXPPAX7PvrvhqJNPTeMntkJWssYVxzPLJ4lB9ufCBcVzBh8cgptnMv1XlsYzYWowRISimh_ky-wc\" alt=\"\"\/><\/figure>\n\n\n\n<p>Open a browser and point to the server that is running Docker and hosting your container.<\/p>\n\n\n\n<p>If you are using an EC2 instance, this is the Public DNS value for the server, which is the same address you use to connect to the instance with SSH. Make sure that the security group for your instance allows inbound traffic on port 80.<\/p>\n\n\n\n<p>In our case, the public IP address is: <strong>18.141.140.63<\/strong> <\/p>\n\n\n\n<p><img src=\"https:\/\/lh6.googleusercontent.com\/4o4qw5_QdfezC2yTpCLLqj7e5idakzKMBqHgOrSxrr-wqomUddQ6EtQG6dVkCXqZ8lZB5unVzmcKC0Sdhn90oi8M7822JDJTrf6Dino6J0oA_ExbdVFCek_R2bOtGr4I48yp14o\" style=\"width: undefinedpx;\"><\/p>\n\n\n\n<p>You should see a web page with your &#8220;Hello World!&#8221; statement.<\/p>\n\n\n\n<p><br><img src=\"https:\/\/lh3.googleusercontent.com\/DQsUGXLxvmcx-JmtfCLLc9QDHkBnSgRKdX6P_cU22z16YcBRYeGVOErcl6Nnz1eT2_L59RyT3CvLitq6QApL6b3c4yA45dxvN4Y6BvSztO9EtJk4mXOTv_Dwq1zaKGJajAZeBIg\" style=\"width: undefinedpx;\"><\/p>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this blog, we have explored the concept of Docker and containerization. We had a look at how to install docker on an EC2 instance, how to create Dockerfiles, and how to build docker images using those Dockerfiles and run the docker container which will run the Apache server. We will see how we can use Amazon ECS for launching and managing your containers. Stay tuned to keep getting all updates about our upcoming new blogs on AWS and relevant technologies.<\/p>\n\n\n\n<p>Meanwhile \u2026<\/p>\n\n\n\n<p><strong>Keep Exploring -&gt; Keep Learning -&gt; Keep Mastering<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At <a href=\"https:\/\/www.workfall.com\/\">Workfall<\/a>, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you\u2019re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at<a href=\"https:\/\/www.workfall.com\/partner\/\"> workfall.com\/partner<\/a> today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> While running Docker on AWS, developers and admins can build, ship, and run highly reliable distributed applications at any scale.&nbsp;&nbsp;In this blog, we will demonstrate how to install, build and run docker containers on Amazon EC2 instances. Refer to Part 1 of the blog here: How To Install And Run Docker Container On Amazon EC2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":218,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[2],"tags":[3,14,15,11,6],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to install and run Docker Containers on Amazon EC2 Instance? - The Workfall Blog<\/title>\n<meta name=\"description\" content=\"While running Docker on AWS, developers, and admins can build, ship, and run highly reliable distributed applications at any scale.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to install and run Docker Containers on Amazon EC2 Instance? - The Workfall Blog\" \/>\n<meta property=\"og:description\" content=\"While running Docker on AWS, developers, and admins can build, ship, and run highly reliable distributed applications at any scale.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/\" \/>\n<meta property=\"og:site_name\" content=\"The Workfall Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/workfall\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-27T14:25:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-22T08:07:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@workfall\" \/>\n<meta name=\"twitter:site\" content=\"@workfall\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Workfall\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\",\"name\":\"Workfall - Hire #Kickass Coders On Demand\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/workfall\/\",\"https:\/\/www.linkedin.com\/company\/workfall\/\",\"https:\/\/facebook.com\/workfall\",\"https:\/\/twitter.com\/workfall\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"contentUrl\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"width\":400,\"height\":400,\"caption\":\"Workfall - Hire #Kickass Coders On Demand\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"name\":\"The Workfall Blog\",\"description\":\"#Tech #Remote #Jobs\",\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#primaryimage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png\",\"width\":1200,\"height\":628,\"caption\":\"Insrall and Run Docker on Amazon EC2 - Workfall\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#webpage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/\",\"name\":\"How to install and run Docker Containers on Amazon EC2 Instance? - The Workfall Blog\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#primaryimage\"},\"datePublished\":\"2021-10-27T14:25:21+00:00\",\"dateModified\":\"2025-08-22T08:07:25+00:00\",\"description\":\"While running Docker on AWS, developers, and admins can build, ship, and run highly reliable distributed applications at any scale.\",\"breadcrumb\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learning.workfall.com\/learning\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install and run Docker Containers on Amazon EC2 Instance?\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#webpage\"},\"author\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\"},\"headline\":\"How to install and run Docker Containers on Amazon EC2 Instance?\",\"datePublished\":\"2021-10-27T14:25:21+00:00\",\"dateModified\":\"2025-08-22T08:07:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#webpage\"},\"wordCount\":765,\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png\",\"keywords\":[\"AWS\",\"containers\",\"docker\",\"ec2\",\"workfall\"],\"articleSection\":[\"AWS Cloud Computing\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\",\"name\":\"Workfall\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"caption\":\"Workfall\"},\"sameAs\":[\"https:\/\/www.workfall.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install and run Docker Containers on Amazon EC2 Instance? - The Workfall Blog","description":"While running Docker on AWS, developers, and admins can build, ship, and run highly reliable distributed applications at any scale.","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:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/","og_locale":"en_US","og_type":"article","og_title":"How to install and run Docker Containers on Amazon EC2 Instance? - The Workfall Blog","og_description":"While running Docker on AWS, developers, and admins can build, ship, and run highly reliable distributed applications at any scale.","og_url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/","og_site_name":"The Workfall Blog","article_publisher":"https:\/\/facebook.com\/workfall","article_published_time":"2021-10-27T14:25:21+00:00","article_modified_time":"2025-08-22T08:07:25+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@workfall","twitter_site":"@workfall","twitter_misc":{"Written by":"Workfall","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization","name":"Workfall - Hire #Kickass Coders On Demand","url":"https:\/\/learning.workfall.com\/learning\/blog\/","sameAs":["https:\/\/www.instagram.com\/workfall\/","https:\/\/www.linkedin.com\/company\/workfall\/","https:\/\/facebook.com\/workfall","https:\/\/twitter.com\/workfall"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","contentUrl":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","width":400,"height":400,"caption":"Workfall - Hire #Kickass Coders On Demand"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website","url":"https:\/\/learning.workfall.com\/learning\/blog\/","name":"The Workfall Blog","description":"#Tech #Remote #Jobs","publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#primaryimage","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png","width":1200,"height":628,"caption":"Insrall and Run Docker on Amazon EC2 - Workfall"},{"@type":"WebPage","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#webpage","url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/","name":"How to install and run Docker Containers on Amazon EC2 Instance? - The Workfall Blog","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#primaryimage"},"datePublished":"2021-10-27T14:25:21+00:00","dateModified":"2025-08-22T08:07:25+00:00","description":"While running Docker on AWS, developers, and admins can build, ship, and run highly reliable distributed applications at any scale.","breadcrumb":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learning.workfall.com\/learning\/blog\/"},{"@type":"ListItem","position":2,"name":"How to install and run Docker Containers on Amazon EC2 Instance?"}]},{"@type":"Article","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#article","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#webpage"},"author":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a"},"headline":"How to install and run Docker Containers on Amazon EC2 Instance?","datePublished":"2021-10-27T14:25:21+00:00","dateModified":"2025-08-22T08:07:25+00:00","mainEntityOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#webpage"},"wordCount":765,"publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/#primaryimage"},"thumbnailUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png","keywords":["AWS","containers","docker","ec2","workfall"],"articleSection":["AWS Cloud Computing"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a","name":"Workfall","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","caption":"Workfall"},"sameAs":["https:\/\/www.workfall.com"]}]}},"jetpack_featured_media_url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png","jetpack-related-posts":[{"id":635,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-container-on-amazon-ec2-instance-part-1\/","url_meta":{"origin":215,"position":0},"title":"How to install and run Docker Container on Amazon EC2 Instance (Part 1)?","date":"November 11, 2021","format":false,"excerpt":"The fast rise in interest and use of container-based solutions has necessitated the development of industry standards for container technology and the packaging of software code. Docker is currently one of the most well-known and widely utilized container engines on the market. Docker was launched in 2013 by a company\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Running Docker on Amazon EC2","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-4.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2266,"url":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/","url_meta":{"origin":215,"position":1},"title":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions","date":"May 16, 2023","format":false,"excerpt":"When Rust compiles code, you get an executable if you created the application using the --bin command. In this blog, we shall look at how we can create a Dockerfile to create an image with this executable. We shall then deploy this image on EC2 using GitHub Actions which will\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":125,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-train-a-deep-learning-model-with-aws-deep-learning-containers-on-amazon-ec2\/","url_meta":{"origin":215,"position":2},"title":"How to train a Deep Learning model with AWS Deep Learning Containers on Amazon EC2?","date":"October 26, 2021","format":false,"excerpt":"Data scientists, machine learning engineers, and practitioners must devote significant time and resources to developing, testing, updating, and optimizing Docker images for deep learning. Instead of concentrating on developing and enhancing models, practitioners are forced to divert valuable resources to unrelated tasks. Installing packages, resolving compatibility concerns, performance optimization, and\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Train a Deep Learning model with AWS Deep Learning Containers on Amazon EC2","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/CoverImages_1200x628px-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2287,"url":"https:\/\/learning.workfall.com\/learning\/blog\/reverse-proxy-mastery-deploying-a-full-stack-application-with-multi-container-docker-and-nginx\/","url_meta":{"origin":215,"position":3},"title":"Reverse Proxy Mastery: Deploying a Full-Stack Application with Multi-Container Docker and Nginx","date":"May 23, 2023","format":false,"excerpt":"Sometimes, developing a full-stack application is not the end of the journey for a web developer. Let us take a case scenario whereby, you have a backend, a frontend, and also a database. For such a setup, we would like to make it easy to replicate our application in different\u2026","rel":"","context":"In &quot;Frontend Development&quot;","img":{"alt_text":"Reverse Proxy Mastery: Deploying a Full-Stack Application with Multi-Container Docker and Nginx","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":464,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-establish-and-maintain-a-scalable-network-using-amazon-managed-blockchain-part-2\/","url_meta":{"origin":215,"position":4},"title":"How to establish and maintain a scalable network using Amazon Managed Blockchain (Part 2)?","date":"November 9, 2021","format":false,"excerpt":"In our previous blog on how to establish and maintain a scalable network using Amazon Managed Blockchain (Part 1), we discussed Blockchain and Amazon Managed Blockchain. We have also discussed its components, benefits, features, pricing, customers, and how it works. In this blog, we will discuss how to use AWS\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Amazon Managed Blockchain","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/blockchain2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":621,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-run-fault-tolerant-workloads-for-up-to-90-off-using-amazon-ec2-spot-instances\/","url_meta":{"origin":215,"position":5},"title":"How to run fault-tolerant workloads for up to 90% off using Amazon EC2 Spot Instances?","date":"November 11, 2021","format":false,"excerpt":"Understanding cloud bills and how to get the most out of the budget on AWS is becoming increasingly important as enterprises migrate more applications and services to the cloud and a larger portion of IT budgets is diverted to cloud providers. With specialized tools, economic models, and best practices, AWS\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Cost Optimization with EC2 Spot Instances","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/spot.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/215"}],"collection":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/comments?post=215"}],"version-history":[{"count":8,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":2538,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/215\/revisions\/2538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media\/218"}],"wp:attachment":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media?parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/categories?post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/tags?post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}