To Run ASP.net vNext on Docker

Microsoft recently announced that the future of .NET will be portable and open source. In addition to the monolithic .net Framework, .net Core will be released as individual packages on NuGet. Among other exciting possibilities, this means we can run ASP.net vNext inside a Docker Container. Unfortunately, as of 12/7/2014, this sample does not work unless we make a minor correction. 

Before we go over the solution, let's describe the error. First, we need to set up a CoreOS instance. Once CoreOS is up, SSH to it and follow the instructions. At the end, the docker container does not start correctly when runing "docker --tls run -d -t -p 8080:5000 myapp". To find out what happened, edit the second Dockerfile and remove the last line (ENTRYPOINT ["k", "web"]). Next, execute "docker run -it myapp". This opens an interactive session to the myapp container, from which we can run "k web" manually. Doing so yields the following exception:

System.InvalidOperationException: No service for type 'Microsoft.Framework.DependencyInjection.ServiceLookup.IServiceManifest' has been registered.
  at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService (IServiceProvider provider, System.Type serviceType) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService[IServiceManifest] (IServiceProvider provider) [0x00000] in <filename unknown>:0
  at Microsoft.AspNet.Hosting.HostingServices.Import (IServiceProvider fallbackProvider) [0x00000] in <filename unknown>:0
  at Microsoft.AspNet.Hosting.HostingServices.Create (IServiceProvider fallbackServices, IConfiguration configuration) [0x00000] in <filename unknown>:0
  at Microsoft.AspNet.Hosting.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
root@10f8b18bf367:/app/src/helloworldweb#

As a temporary work around, we can use an older version of the KVM install script from the dev branch instead of the master branch. In the original instructions, within the first Dockerfile, replace the line

"RUN curl -s https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh"

With 

"RUN curl -s https://raw.githubusercontent.com/aspnet/Home/dev/kvminstall.sh | sh"

Then the rest of the sample should work as intended. Please let me know in the comments if this workaround did the trick.

Note: "k web" runs the sample using the Nowin vNext server. This appears to be the only server that currently works on Linux (WebListener is unavailable on Linux and Kestrel has issues with Libuv). I have created a sample to demonstrate this.