Download and install Docker for Windows

At the time of writing, click on “Get Doclker for Windows (beta)”. This downloads a file named InstallDocker.msi. Run this file in order to install “Docker for Windows”. Once it is done you should see the whale icon in your system tray.

If you right-click on the whale icon, you will see the following options:

Click on Settings…

Click on “Shared Drives”.

Enable sharing of the C drive and any other drive that you may be using for the working directory when developing your ASP.NET Core 1.0 Web Application with Visual Studio 2015. When you are done, click on Apply then close the “Shared Drives” dialog.

Build your ASP.NET Core 1.0 web application in Visual Studio 2015

I am using Visual Studio 2015 to build an ASP.NET Core 1.0 application. Note that you can also use Visual Studio Code instead.

Select the “Web Application” template, make sure authentication is “No Authentication” to keep it as simple as possible. Also make sure “Host in the cloud” is unchecked then click on OK.
Wait a while while dependencies are restored then hit “Ctrl + F5” on the keyboard to run the application. This what your default browser should look like:

Close your browser.

Open the project.json file in Visual Studio. The first “dependencies” JSON block suggests that our application is running ASP.NET Core 1.0.1:

Copy current directory on the host computer to /app in the Linux container

Open a command line in the web application folder (in my case src/WebApp4Docker) and execute the following:

dotnet publish

Copy Dockerfile from src/WebApp4Docker to src\WebApp4Docker\bin\Debug\netcoreapp1.0\publish.
Execute the following command to build an image that contains our web application in a Linux container:

docker build bin\Debug\netcoreapp1.0\publish -t asplinux

Run the image named asplinux that was just created in the background where port 80 in the container is mapped to port 8001 on the host computer:

docker run -d -p 8001:80 asplinux

To see which container is running in the background, type the following in the command line:

docker ps

You will see output similar to the following:

Now we should see the fruit of our hard work by experiencing our container deployed web application in a browser on the host. Open your favorite browser on your computer and go to http://localhost:8001. You should see the following:

Cleaning up

Let us stop the container and clean up the image.

To see which containers are running, type the following:

docker ps

Take note of the container id. In my case it is ee92b47148e1. To stop the container you can simply use the first three character of the id as follows:

docker stop ee9

you can also stop the container by referencing is name, like: docker stop asplinux
To see which containers are still available, type:

docker ps –a

To delete the container completely, identify the first three character of the id then use the “docker rm” command similar to the following:

docker rm ee9

I you run “docker ps –a” again you will determine that the container is gone.
Now let us see if the image named asplinux is still available. To find out, type the following command:

docker images

You can delete the image by id or by name, as follows:

docker rmi f60 OR docker rmi asplinux
After you remove the image you can again type “docker images” to prove that our asplinux image is deleted.

In my next post I will discuss using a windows nano-server instead of Linux.