M
M
Mariik2019-01-31 02:30:05
JavaScript
Mariik, 2019-01-31 02:30:05

How does Docker on Windows remap ports?

There is a simple application on the node that runs inside the container

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('***** Hello World!');
});

app.listen(3000, function () {
  console.log('****** Example app listening on port 3000! *****');

I'm trying to make it available via localhost:3000
When I start the container, I'm trying to remap the ports:
docker run -p 3000:3000 <id>
And nothing.... Requesting localhost:3000 returns nothing at all....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2019-01-31
@fox_12

> docker run -p 3000:3000
> And nothing.... At the request of localhost:30000
Duc run on 3000, and check 30000?
Tell the node to listen on 0.0.0.0 in addition to specifying the port. And then the node you have on 127.0.0.1 by default inside the container listens - that's the port and is not forwarded to the outside.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question