In this tutorial we will create a WebAPI application with the full version of ASP.NET. We will then host it with IIS in a Windows Server Core instance using Windows Containers and Docker.
![]()
The biggest totally free game fix & trainer library online for PC Games https://gamecopyworld.com. I upgraded from Windows 8.1 to Windows 10. For the first three days, my windows update was working perfectly. However, I have not been able to install or check for any updates since 7/31.
If you have Windows 10 Pro or Enterprise installed on your PC or laptop then there's some great news for you. You can run Windows Nano Server and Windows Server Core without having to set up Windows Server 2016 in a virtual machine!
If you're following along now then you'll need Windows 10 to hand and will have already installed Docker with the instructions available here:
Docker for Windows installation from MSDN
Microsoft has provided two images for the new Windows Server editions: Server Core and Nano Server. Nano Server is being pitched as a minimalist OS - so minimal that it lacks a full version of PowerShell and cannot install programs using MSI files.
We will pull down a Windows Server Core image as a basis for our container.
docker run
Let's start a command prompt in a docker container to check that everything worked. If it's the first time you've run this command then Docker will pull down around a 4GB download.
My system has started a Windows Server Core container and has given me a minimal filesystem. How long did this take? For me it was around 5 seconds and that's because Windows 10 uses Hyper-V isolation to launch each container.
If you want to clean up your containers then it turns out PowerShell has the same syntax as bash:
docker rm -vf $(docker ps -qa)
Visual Studio 15
In the meantime install Visual Studio 15 Community edition so that we can create an ASP.NET application.
The download and installation will take some time. You can skip the next step if you want to but will still need to build the code through Visual Studio or
msbuild .
Github repository alexellis/guidgenerator-aspnet
Create a WebAPI application
Create a WebAPI application, build it and save it.
Click Web and then .NET 4.5.1.
Pick Web API.
I didn't spend too long here - I just edited the ValuesController so that it will create a GUID for us. See below:
This is what I got from running the code on my own machine in debug mode (hit F5 in Visual Studio).
Next we'll create a Dockerfile for IIS and .NET and then finally run the code in a Windows Container through Docker.
.NET Dockerfile?
Let's create an outline for a .NET + IIS Dockerfile then enhance it.
There is a base image provided by Microsoft which already contains IIS, we'll use that as a template. As best practices would have use do - we'll pin ourselves to a specific tag or version of the image.
You can see all the tags on the Microsoft repo on the Docker Hub.
We'll introduce a new Dockerfile instruction called
SHELL which allows us to specify which shell or command line interpreter to use for each RUN step. The SHELL value could be cmd or powershell or something completely different.
Read about the SHELL instruction in the Dockerfile reference.
![]()
To make sure we only get a single layer for .NET and ASP.NET features we will use a
; to separate each command and then a to go multi-line.
When you start to build this Docker image, you'll get useful information back from Powershell telling you what's going on:
Edit the Dockerfile
At this point we'll add the code to the container and create a new site in IIS along with an application pool. We also want to remove the default website because less is more.
If you think the
CMD instruction looks out of place then you're right. We need to give the container a long-running task otherwise it will quit immediately.
Docker's Michael Friis suggested that the
ping command may fill up the container logs and suggested using a wait loop instead. It would look a bit like this:
Update 6th Jan 2017: Microsoft has started to bundle ServiceMonitor.exe with the IIS container which means you no longer need the above while/sleep loop.
Create an image
Now build the image and run it:
Use
-p 80:80 to expose port 80 from IIS.
Once the container is running we'll need to find its IP address. This command can help us pick it out of the metadata supplied by
docker inspect .
Use the container's IP address in a web browser or with curl to generate as many Guids as you like:
Run metrics
You can even use Apache Bench to generate some metrics. If you have the Ubuntu Subsystem for Windows then install the package and run some tests:
Wrapping up
So to wrap up, we've just:
Update 6th Jan 2017: Microsoft has started to bundle ServiceMonitor.exe with the IIS container which means you no longer need the above while/sleep loop.
The GUID generator source code is available here on my Github repository alexellis/guidgenerator-aspnet.
You can use this sample if you did not create a brand new project of your own, but make sure you build the code and carry out a NuGet restore.
Enjoyed the tutorial? 🤓💻
Follow me on Twitter @alexellisuk to keep up to date with new content. Feel free to reach out if you have any questions, comments, suggestions.
Enjoyed the tutorial? 🤓💻
Follow me on Twitter @alexellisuk to keep up to date with new content. Feel free to reach out if you have any questions, comments, suggestions.
Hire me to help you with Kubernetes / Cloud Native
Hire me via OpenFaaS Ltd by emailing [email protected], or through my work calendar. Let me know whether you need help with Windows Containers .NET/.NET Core migration, Jenkins or something else.
See alsoThis is a game for the young players (it is recommended for ages between 3 and 8), so consider that I am FAR off this range, and my opinions on it might not match a kid's... That said, on with the game!
In this game we have the task of helping a litle boy - Alex - to build the farm of his dreams.
There are versions that bring the Alex figure - I got this one (see picture). Apparently the German one has a free poster (I prefer the figure!).
We control the boy, and we can run around a virtual 3D playmobil® world, meet other characters, and many fun activities in between.
A 3D card is required for this game, and we need the CD to play.
The game has a pretty good instruction booklet, which besides the installation procedures and controls explanation includes a very helpful map of Alex's place, so we can more easily move about.
The controls are very simple, and in the box there are colored transparent stickers to put over the used keys, to make it easier for kids to id the blue spacebar Alex (constantly) refers to in the game.
The game has an absolutely GORGEOUS intro, with a flyover of the whole place.
Queen Tahra, December 2001
page 1 | page 2 | page 3
Back to... Library > Playmobil® Interactive
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |