2

I am working through this blog post which explains how to host a sample ServiceStack app on .net core via Docker.

In the command line I see:

Now listening on: https://*:5000

But as shown in the below screenshot, nothing seems to be hosted on localhost port 5000.

Docker not hosting anything

I have tried this on my Mac and PC and it's the same result.

I am brand new to Docker so I'm assuming this something obvious on my part so apologies for the noob question!

Thanks

3
  • Did you open and redirect a port from the container to your app? By default, apps running in the container can't be reached from outside it, unless you add port mapping to route a outside port to a port inside the container (similar to how NAT works)
    – Tseng
    Dec 23, 2016 at 18:50
  • @Tseng nope, brand new to Docker, can you link to a resource showing how to do this? Thanks
    – JMK
    Dec 23, 2016 at 18:50
  • 1
    -P outsideport:innerport, i.e. -P 443:5000, then you'd connect with https://localhost/ to it
    – Tseng
    Dec 23, 2016 at 18:53

1 Answer 1

4

By default docker containers do not expose any ports to the world outside of the container. When you start a container, you need to add a port mapping similar to NAT so it can be reached form outside (docs).

When you run docker run you need to pass the port mappings via -p IP:host_port:container_port parameter, i.e. docker run -p 443:5000. Then connect to it via https://localhost (https is on port 443).

4
  • I get what you are saying, however this isn't working for me either. The CLI isn't complaining about the -p argument, but still can't connect via the browser. Any thoughts?
    – JMK
    Dec 23, 2016 at 18:58
  • 1
    Not sure how docker is implemented on windows, but for the low ports (ports <= 1024), one requires administrative privileges. If unsure, try it with a higher port or run the powershell as admin
    – Tseng
    Dec 23, 2016 at 19:00
  • Alternatively execute netsh http add urlacl url=http://+:80 user=DOMAIN\username as Administrator, this adds the permission to the given user to bind to ports <= 1024 w/o administrative priviledges
    – Tseng
    Dec 23, 2016 at 19:03
  • Still no joy unfortunately @Tseng, either on Windows or Mac OS, very odd!
    – JMK
    Dec 23, 2016 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.