Docker EXPOSE. Can't get it

前端 未结 1 1988
夕颜
夕颜 2021-01-04 06:22

this past two day I\'m having trouble with docker and i can get it. Following to the docker doc you can expose the ports on which a container will listen for connections wi

相关标签:
1条回答
  • 2021-01-04 06:45

    In your nodejs app, you have the instruction app.listen(PORT); which tells nodejs to start a server listening for connections on the loopback interface on port PORT. As a result your app will only by able to see connections originating from localhost (the container itself).

    You need to tell your app to listen on all interfaces on port PORT:

    app.listen(PORT, "0.0.0.0");
    

    This way it will see the connections originating from outside your Docker container.

    0 讨论(0)
提交回复
热议问题