Starting Dotnet aspnet core 1.1 on OSX in a Docker container
Install Docker on OSX.
Prepare local drive
(This is strictly not necessary but if you skip this you have to remove the -v and following path from the docker run command further down. You will also have to mkdir the app folder in the container before cd to it.)
Go to you your local Documents folder. Create a Docker folder. Inside it create a dotnetcore folder. This results in /Users/myname/Documents/Docker/dotnetcore.
Open a terminal and execute (after exchanging “myname” to your user’s name)
docker run -p 80:80 \
-e "ASPNETCORE_URLS=http://+:80" \
-v "/Users/myname/Documents/Docker/dotnetcore:/app" \
-it --rm microsoft/dotnet
This will download the microsoft/dotnet image, start it, connect your host’s dotnetcore folder to an app folder inside the container, set an environment variable, publish the internal port 80 on port 80 and finally open a terminal inside the container; all in one go.
Start the web server
Now inside the container execute
dotnet new -t web
Absolutely not necessary but if you
you will see something like
public class Program
public static void Main(string args)
var host = new WebHostBuilder()
Start the web server through
This will also compile the code before starting the application.
If you open
in your host’s web browser you should now see a page about Dotnet aspnet core.
That all there is to it!
If you don’t check that the web server is running and listening on port 80 locally. This is done by opening a new terminal and check the ContainerID through
Then you attach a terminal to the running container.
docker exec -it d10988067ec8 bash
(but with proper id)
Now, inside the container, run
and you should get a boatload of HTML back. In the other terminal window you should see some reaction to the request.
More thourough but for version 1.0