{"id":37170,"date":"2019-06-19T06:00:27","date_gmt":"2019-06-19T13:00:27","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/premier-developer\/?p=37170"},"modified":"2019-06-05T12:55:20","modified_gmt":"2019-06-05T19:55:20","slug":"getting-started-with-docker-for-windows","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/getting-started-with-docker-for-windows\/","title":{"rendered":"Getting started with Docker for Windows"},"content":{"rendered":"<p>In part-one in this multi-part series, Sr. App Dev Managers Joseph Flanigen and Bill Bevan show us how to get up and running with Docker.<\/p>\n<hr \/>\n<p>The intention of this two-part blog series is to provide a foundational understanding of Docker from Docker installation through Azure Web App deployment. After a brief overview of Docker itself, we\u2019ll dive right in by getting Docker installed and configured. Next, we will show you how to get up and running with a simple sample app and expand from there.<\/p>\n<h3>A brief recap of the journey to Docker containers<\/h3>\n<p>Developing, testing, and deploying enterprise applications has become increasing complicated and costly over the years. Fifteen years ago, it was common to run enterprise applications exclusively on physical hardware. Ten years ago, physical machines started to be replaced by virtual machines, increasing scaling and reliability opportunities. Each of these milestones essentially targeted increased performance and decreased administration overhead. Five years ago, a company called Docker introduced standards to virtualize at the application layer, a.k.a. \u2018Containerization\u2019.<\/p>\n<h3>What Is Docker?<\/h3>\n<p>Docker is both a company and a technology that enables users to package their application software in a way that allows the application to run in a variety of environments or \u2018containers\u2019 with minimal configuration changes. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings. Once the application and its underlying components are packaged into a Docker \u2018image\u2019, the application can run within a local container or a variety of virtual environments. This includes, but is not limited to Azure, AWS and other cloud providers supporting Kubernetes or Docker image orchestration services like Service Fabric. Read more about Docker <a href=\"https:\/\/www.docker.com\/why-docker\">here<\/a>.<\/p>\n<h3>Get Docker<\/h3>\n<p>Begin by navigating to <a href=\"https:\/\/hub.docker.com\/editions\/community\/docker-ce-desktop-windows\">Docker Desktop for Windows<\/a> to download the installer. Before being able to download, a Docker Account must be created and used to sign in at the Docker website and installation base images.<\/p>\n<p><img decoding=\"async\" width=\"924\" height=\"1208\" class=\"wp-image-37171\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-1.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-1.png 924w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-1-229x300.png 229w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-1-768x1004.png 768w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-1-783x1024.png 783w\" sizes=\"(max-width: 924px) 100vw, 924px\" \/><\/p>\n<h3>Download \/ Install Package<\/h3>\n<p>During the installation process, your machine most likely will proceed through some sign outs and reboots. Certainly, enable the Hyper-V and Containers features.<\/p>\n<p><img decoding=\"async\" width=\"1393\" height=\"520\" class=\"wp-image-37172\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-2.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-2.png 1393w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-2-300x112.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-2-768x287.png 768w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-2-1024x382.png 1024w\" sizes=\"(max-width: 1393px) 100vw, 1393px\" \/><\/p>\n<h3>Ensure TPM configuration<\/h3>\n<p>During installation and setup of Docker, if you happen to be running into an issue with Hyper-V, please reference the following link for steps to enable Hyper-V in Windows 10.<\/p>\n<p><a href=\"https:\/\/nam06.safelinks.protection.outlook.com\/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fvirtualization%2Fhyper-v-on-windows%2Fquick-start%2Fenable-hyper-v&amp;data=02%7C01%7CBill.Bevan%40microsoft.com%7C73cd6b140d43465d60fa08d66b7d2569%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636814582583914336&amp;sdata=hsPZvuyKOul5EXT5DFmiEgGGpyQLRRl5yTO4TB8%2Fgt4%3D&amp;reserved=0\">Install Hyper-V on Windows 10<\/a><\/p>\n<p>For some machines you might have to go into the BIOS to enable Virtualization as well. If this is a corporate asset with BitLocker enabled, remember to suspend BitLocker before making any needed BIOS changes.<\/p>\n<p>In Windows Search, type <strong>manage BitLocker<\/strong> to bring up the configuration window as shown below. Click <strong>Suspend protection<\/strong> before making any changes to the BIOS.<\/p>\n<p><img decoding=\"async\" width=\"618\" height=\"205\" class=\"wp-image-37173\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-3.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-3.png 618w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-3-300x100.png 300w\" sizes=\"(max-width: 618px) 100vw, 618px\" \/><\/p>\n<p>(<em>WARNING<\/em>: Only if needed) In the BIOS of your machine go into Security \/ Virtualization to enable virtualization. In most cases you will not need to do the above steps in the BIOS.<\/p>\n<p>Eventually your Docker Desktop installation is completed! <img decoding=\"async\" width=\"726\" height=\"1270\" class=\"wp-image-37174\" src=\"http:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-4.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-4.png 726w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-4-171x300.png 171w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2019\/06\/word-image-4-585x1024.png 585w\" sizes=\"(max-width: 726px) 100vw, 726px\" \/><\/p>\n<h3>Build Static Website with IIS and run locally<\/h3>\n<p>The following walkthrough will enable you to build a Docker image that contains simple HTML page deployed to the Microsoft IIS base image container.<\/p>\n<p>The below steps could easily be augmented to \u2018lift-and-shift\u2019 a simple website from a VM or dedicated Webserver to a Docker image ready for container deployment. You can simply cut and paste your web assets into the \\site directory run a new Docker build.<\/p>\n<h3>Prepare your local Docker Environment<\/h3>\n<p>To create the image, we\u2019ll need to create a subdirector and 2 files and a local subdirectory, specifically:<\/p>\n<ul>\n<li>Folder Structure\n<ul>\n<li>Create a directory called \u2018simpleWebImage\u2019<\/li>\n<li>Within \u2018simpleWebImage\u2019, create a subdirectory called \u2018site\u2019<\/li>\n<\/ul>\n<\/li>\n<li>Files\n<ul>\n<li>simpleWebImage.dockerfile \u2013 This is the required configuration file that details the behavior of the container environment. This specific configuration requests Microsoft\/IIS base image and then copies all contents of the \u2018site\u2019 subdirectory into the default wwwroot of the Microsoft IIS instance.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p style=\"padding-left: 90px;\"><strong><em>simpleWebImage.dockerfile<\/em><\/strong><\/p>\n<pre class=\"lang:default decode:true\" style=\"padding-left: 60px;\">FROM microsoft\/iis\r\nCOPY \/site\/ \/inetpub\/wwwroot<\/pre>\n<p style=\"padding-left: 90px;\"><strong><em>index.html<\/em><\/strong><\/p>\n<pre class=\"lang:default decode:true\">&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;body&gt;This is a Hello World being served up by a Windows 2016 IIS Web Server running within a Docker container&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h3>Build It \/ Run It<\/h3>\n<ul style=\"list-style-type: disc;\">\n<li>Go to the subdirectory that contains your \u2018simpleWebImage\u2019dockerfile and \u2018site\u2019 subdirectory<\/li>\n<li>Open a PowerShell Window in Admin Mode<\/li>\n<li>To build the image, run the following command:<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">docker build -f simpleWebImage.dockerfile -t simplehello<\/pre>\n<p style=\"padding-left: 90px;\">The \u2018-f\u2019 flag allows you to override the \u2018dockerfile\u2019 default and point to a specific file of your choosing.<\/p>\n<p style=\"padding-left: 90px;\">\u2018simplehello\u2019 is the proper \/ friendly name of the resulting image we provided and will use to run or manage the image later.<\/p>\n<ul>\n<li>Once the above command runs, your image will be placed into the local repository. To verify, run the following command to get a list of local repository images:<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">docker image ls<\/pre>\n<ul>\n<li>To execute the image in a local container, run the following command:<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">docker run -p 8000:80 simplehello<\/pre>\n<ul>\n<li>To verify that the container image is responding as expected, validate through the following:\n<ol>\n<li>Visually:\n<ol>\n<li>Open your web browser<\/li>\n<li>Go to <a href=\"http:\/\/localhost:8000\">http:\/\/localhost:8000<\/a><\/li>\n<li>You should get back a basic hello world response<\/li>\n<\/ol>\n<\/li>\n<li>Through command-line:\n<ol>\n<li>type <em>docker container ls<\/em><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h3>End the Process \/ Stop the Container<\/h3>\n<p>In Windows, you need to explicitly stop or \u2018kill\u2019 the container to stop the Docker image from running locally. To stop the container:<\/p>\n<ul>\n<li>At the command prompt, type the following:<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">docker container ls<\/pre>\n<p style=\"padding-left: 60px;\">Note the Container ID in the list, as you\u2019ll use it in the next step<\/p>\n<ul>\n<li>Type in the following:<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">docker kill &lt;Container ID&gt;<\/pre>\n<h3>Summary<\/h3>\n<p>With simple steps, we were up and running with Docker in no time. In part two, we\u2019ll take this example to Azure and explore the all deployment and performance options Azure has to offer!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this walkthrough, our App Dev Managers show how to install, configure and containerize a simple webapp to help you get up and running with Docker.<\/p>\n","protected":false},"author":582,"featured_media":37840,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[129,55],"tags":[29,3],"class_list":["post-37170","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-premier","category-web","tag-docker","tag-team"],"acf":[],"blog_post_summary":"<p>In this walkthrough, our App Dev Managers show how to install, configure and containerize a simple webapp to help you get up and running with Docker.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/37170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=37170"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/37170\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/37840"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=37170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=37170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=37170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}