LET’S TALK DOCKER (PART–2): Dock on Windows
Contributor: Sharif Abdullah, Nascenia
This article is a continuation of Let’s Talk Docker (Part-1)
Install Docker Tool Box:
1. Windows 7 or higher
2. Make sure your CPU supports “virtualization technology” and virtualization support is enabled in BIOS and recognized by Windows.
Virtualization support for Windows 8, 8.1 or 10
Choose Start > Task Manager.
Navigate to Performance tab. Under CPU you should see the following:
If virtualization is not enabled on your system, follow the manufacturer’s instructions for enabling it.
Virtualization support for Windows 7
Run the Microsoft® Hardware-Assisted Virtualization Detection Tool and follow the on-screen instructions.
If you have VirtualBox running, you must shut it down before running the installer.
- Go to the Docker Toolbox page.
- Click the installer link to download.
- Install Docker Toolbox by double-clicking the installer. The installer launches the “Setup – Docker Toolbox” dialog.
- Press “Next” to install the toolbox.
The installer presents you with options to customize the standard installation. By default, the standard Docker Toolbox installation:
- installs executables for the Docker tools in C:\Program Files\Docker Toolbox
- install VirtualBox; or updates any existing installation
- adds a Docker Inc. folder to your program shortcuts
- updates your PATH environment variable
- adds desktop icons for the Docker Quick start Terminal and Kitematic
5. Press “Next” until you reach the “Ready to Install” page. The system prompts you for your password.
6. Press “Install” to continue with the installation. When it completes, the installer provides you with some information you can use to complete some common tasks.
7. Press “Finish” to exit. After Installation you will have these 2 icons in your desktop. One is Docker terminal and another is virtual box UI.
Walk through: Create an Asp.Net app and deploy it into Docker container
Here we’ll go through a quick demo of setting up an empty ASP.NET 5 web application and get it running inside a Docker container on Windows. We’ll go through all the steps necessary to link our project source code into the Docker container and have it run our website. In the end we’ll be able to fire up a view the website running in Docker.
1. Create a new project
Nothing fancy here, let’s create an ASP.NET 5 preview template Web application.
– Select ASP.NET Web Application.
– Now if I try to browse localhost:5000 I will see this:
Inside the docker file the following commands should be present:
COPY . /app
RUN [“dnu”, “restore”]
ENTRYPOINT [“dnx”, “-p”, “project.json”,”web”]
We need to change in the project.json file for setting the port. Change the commands property like this:
“web”: “Microsoft.AspNet.Server.Kestrel –server.urls http://0.0.0.0:5000”,
3. Now start the “Docker Quickstart Terminal”:
It take few minutes to start, if terminal starts successfully you will see this in the terminal:
Now we will build docker image by using that docker file. For that we need to go the folder where the project is located. For my case it is in
You can see the all folders and files by ‘dir’ command. Then go project directory:
Then run the docker build command,
This command will create an image named dockerdemo, you can give any name after that ‘-t’ . The build command will take few minutes to download the dependencies and install them.After the command finished successfully then if you run ‘docker images’ you can see you image listed there.
Now it is time to run a docker container. Docker run commands are like following:
$ docker run -d -p port_number: port_number my_image
So lets run the docker command:
$ docker run -d -p 5000: 5000 dockerdemo
Now we have some few works to do. We need to do port forwarding to virtual box. Open Virtual box and open the settings by right clicking the default running machine.
Then click on Network->Port Forwarding. You will have a pop up opend. Then click on ‘+’ sign to add new port forwarding rules. Give it a name give the ip adress as the Host Pc local address and make that port 5000:
Now if you go to browser and browse to http://localhost:5000/, you can see the Asp.Net Home page of the app.