-1

I have Windows 10 Home, so have Docker Toolbox installed, and therefore run my containers on a VirtualBox VM.

This example from the Docker docs worked perfectly:

https://docs.docker.com/get-started/part2/

I set up port forwarding on the VM so that 8000 on localhost mapped to 8080 on the guest machine, fired up the container using

docker container run --rm --detach -p 8000:8080 <image name>

and could access the site by going to 192.168.99.100:8000 in a browser on the host machine, or curl at the command line. No problems whatsoever.

However, whenever I try to put an ASP.NET Core website into a container in the same way, I'm unable to access it, I constantly get a 404.

I assumed that I had something missing in my Dockerfile (even though the image builds successfully), so, to eliminate that, I wanted to try a couple of pre-created images from here:

https://www.hanselman.com/blog/GettingStartedWithNETCoreAndDockerAndTheMicrosoftContainerRegistry.aspx

Again, the console app worked perfectly, but the website again cannot be found (I changed the -p argument to 8000:8080 to match what I have set up).

I'm at a bit of a loss to understand what the problem is here.

dyson
  • 866
  • 6
  • 12

1 Answers1

0

In the end, this was resolved by adding

.UseUrls("http://*:8080")

to the Program.CreateWebHostBuilder method, and then adding

ENV ASPNETCORE_URLS=http://+:8080 EXPOSE 8080

to the Dockerfile, as detailed here: https://stackoverflow.com/a/40836125/3170822

dyson
  • 866
  • 6
  • 12