Dockerfile which can be used to build fully functional ASP.NET vNext application as a Docker Container.
- Put Dockerfile inside of your ASP.NET vNext project where you have Startup.cs and project.json files.
- Run the command
docker build -t yourProjectName .
- If your project contains dependencies to lots of libraries such as MVC, go get some coffee.
- To launch the web application execute command
docker run -t -d -p [PORT]:5004 yourProjectName
- You're now live on the specified [PORT].
- Execute
docker ps
and identify your app container id. - Execute
docker stop [container id]
- Execute
docker ps
and identify your app container id. - Execute
docker restart -t=1 [container id]
If you want to perform a quick fix inside of the running app, follow the steps:
- Execute
docker ps
to see the list of running apps. Identify your app container id. - Run
docker exec -i -t [container id] /bin/bash
- You are now in the bash console inside of your container. To exit bash, just
exit
. - Restart the app (see previous paragraph).
I've came accross the problem, where I've finally ran the application, but it has no styling. The issue was the naming of the _ViewStart.cshtml file. Solution?
- Rename
_ViewStart.cshtml
from ViewsFolder to_viewstart.cshtml
This is another issue which effectively stopped me for a while when I tried to build the app. It was caused by missing command in project.json.
- Make sure your commands section in
project.json
looks like this:
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"gen": "Microsoft.Framework.CodeGeneration",
"ef": "EntityFramework.Commands",
/* kestrel command is required when you run app on linux */
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004"
},