Troubles with mapping ports on a very simple Docker container I'm new to Docker and following a tutorial on Udemy.com. The turtorial has me setting and running a very simple container.

Docker File

# Specify a base image
FROM node:alpine

# Putting files into a specific directory
WORKDIR /usr/app

# Install some dependencies
COPY ./package.json ./
RUN npm install
COPY ./ ./

# Default command
CMD ["npm", "start"]


Index.js

const express = require('express');

const app = express();

app.get('/', (req, res) =&gt; {
    res.send('Hi there');
});

app.listen(5000, () =&gt; {
    console.log('Listening on port 5000');
});


package.json

{
    "dependencies": {
        "express": "*"
    },
    "scripts": {
        "start": "node index.js"
    }
}


I'm working on a laptop running Windows 10 Home. Using the Docker Quickstart Terminal and PowerShell.

I've edited my HOSTS file as to point localhost to 192.168.99.100, which is the ip the container gets.

I've tried hitting the server by both 192.168.99.100:5000 and localhost:5000. No matter what, when I try to access via browser(I.E. and Chrome) I get the following message:

This site can’t be reached

192.168.99.100 refused to connect.




  curl http://192.168.99.100:5000


returns


  curl: (7) Failed to connect to 192.168.99.100 port 5000: Connection refused




However, If I run 'docker-machine ls', I get:


  tcp://192.168.99.100:2376


Why port 2376? I cannot figure out where/how this port is being assigned.

Trying the browser on that port I get a different message:

This page isn’t working

192.168.99.100 sent an invalid response.

ERR_INVALID_HTTP_RESPONSE



This would suggest(at least to me) that the server is there on that port, but not doing something right.

curl http://192.168.99.100:2376 --output -


Gives me some garbled output in the terminal, and writing it to a file gives garbled output as well. Not much, just a few garbage characters.

I suspect this is the "Hi There" message that is not being formatted correctly.

So my questions would be, am I doing something wrong in my dockerfile? Why/how is the container getting this port 2376 when i'm specifically mapping to 5000?

Any insight would be appreciated.
May be you are using bridge network mode. In that case, you need to bind your host port to container port to use same port. 
So when you execute docker run, you may need to add 
-p 5000:5000 as a flag to docker run command. Also I don't see any expose in Dockerfile. So you may want to add EXPOSE 5000 in Dockerfile just above cmd.