Core and Docker (vs2015)

At home I have one desktop computer where I do 99% of my work and one old laptop which i installed Ubuntu server on a couple of months ago. I don’t really use it for anything at this point so I got the idea to run my latest project in docker containers on that one. The plan is to use it for testing server.

So, where to start?

You will need core installed on your dev machine and docker on your server. I run git bash on my local dev and ssh server on my ubuntu to be able to send files back and forth.

So, on your dev machine, just create a new core project in visual studio and then run it. If you did everything correctly you should see something like this:

The next step is to create a file called “Dockerfile” in your project folder.


Add this to the file.

What this does is to tell docker to use the microsoft/dotnet image, copy the root dir to app and set that to working directory. After that “dotnet restore” and “dotnet build” will be run. Since we use port 5000 by default we will expose that. Then we will run “dotnet run”.

This is basiclly what we need to do, so let’s build the docker image.

Send it to your server. Since we are using git bash we wont see any progress of the transfering, but when the prompt comes back it should be done. It will likley take a couple of minutes (about 1 gig to transfer)

And run it on your server

At this step you might get an error saying you’ve got the wrong version of .net core. At the time of writing this post the latest version is 1.1.0 and when i create projects in it defaults to 1.0.1. So just change it to 1.1.0 in project.json, rebuild docker image, transfer and try again.
Now the image should be running on your linux machine and by going to :8080 you should get the page.

Leave a Reply

Your email address will not be published. Required fields are marked *