3.0 KiB
aspnet-framework:4.6.2 Sample
This sample demonstrates how to dockerize an ASP.NET Web Forms app that uses .NET Framework 4.6.2 by adding a Dockerfile
to it and running the image with Docker for Windows in a Windows Container. To complete this example you must have Windows 10 Anniversary Edition (or Windows Server 2016) with container support enabled, Docker for Windows (the minimum beta version 1.13), Visual Studio, and Git installed.
Instructions
Note: You must use Windows Containers on Docker for Windows to run this image. Be sure to check that you are properly switched to Windows Containers. Do this by opening the system tray up arrow and right clicking on the Docker whale icon for a popup menu. In the popup menu make sure you select 'Switch to Windows Containers'.
Preparing your Environment
- Git clone this repository or otherwise copy this sample to your machine:
git clone https://github.com/microsoft/dotnet-framework-docker-samples/aspnetapp
- Build the project locally from Visual Studio.
Note: These instructions are command-line-based for simplicity, but you can also run this sample with Docker Tools for Visual Studio 2017 RC.
Build and run the Docker image:
Note: The base image for this sample is microsoft/iis which uses microsoft/windowsservercore which is a minimal install of Windows Server 2016 and about 4 GB in size. Make sure you have enough space availiable on your drive.
- Navigate to the root of your project folder that contains your Dockerfile at the command prompt or terminal.
- Build the Docker image:
docker build -t aspnetapp .
- Run the application in the container:
docker run -d -p 80:80 aspnetapp
View your web page running from your container
There is currently a bug that affects how Windows 10 talks to Containers via "NAT" (Network Address Translation). Today you must hit the IP of the container directly. You can get the IP address of your container with the following steps:
- Run
docker ps
and copy the hash of your container ID - Run
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" HASH
whereHASH
is replaced with your container ID. - Copy the container ip address and paste into your browser with port 80. (Ex: 172.16.240.197:80)