TL;DR

Change the "commands" > "web" entry in project.json to look like this:

  { "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://0.0.0.0:5000" }

Details

I'm just going to admit this straight out: that title is intended to get hit by searches. I've helped a couple of people solve this problem on Twitter now, so I think a quick blog post is in order.

In ASP.NET 5 (DNX) pre-beta8, if you were working on Linux/Mac and using the Yeoman generator (it's the only way to live, people) there was a hosting.ini file included in the generated project which provided the server.urls setting to Kestrel. I can't remember what was in there, but whatever it was worked OK in Docker.

As of beta8, that file is gone, and Kestrel defaults to serving the site on http://localhost:5000. That works fine when you're testing (with live reload using dnx-watch!) directly on your local machine, but when you run the site in a Docker container you'll find you get a message Connection Refused when you try to browse to it, or when the Nginx proxy you're using in production tries to send requests upstream.

I actually learned this about Docker while fiddling with a Node.js project, but it applies to DNX as well: the Docker network bridge won't map requests to ports opened on the loopback address (127.0.0.1, or localhost). You have to specify the 0.0.0.0 address, which means "all IP addresses on this machine". In a Docker container, that includes the network bridge IP address, so everything works as it should.

The way to specify this in DNX is to pass the server.urls parameter to Kestrel (the HTTP server). You just pass it in the web command in project.json, as shown at the top of the post. Obviously you can change the port to whatever you want; personally I leave it on 5000 because I run every site/service in separate containers, as the gods intended.