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"]


const express = require('express');

const app = express();

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

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


    "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, which is the ip the container gets.

I've tried hitting the server by both 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 refused to connect.



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

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


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 sent an invalid response.


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

curl --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.

  • You need to expose the ports either by adding them in your dockerfile or add arguments while starting container. Look at deosha's answer. – KatariaA Mar 26 '19 at 13:38

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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