简体   繁体   English

在虚拟docker-machine中运行NodeJS服务器-无法访问正在运行的VM应用

[英]Running NodeJS server in virtual docker-machine - Cannot access running VM app

I am going through this docker tutorial in order to get my electrode app working in a VM. 我正在阅读 Docker教程,以使我的Electrode应用程序在VM中工作。

When I run node server.js in the VM it logs a message indicating the Hapi server is running: 当我在VM中运行node server.js时,它会记录一条消息,指示Hapi服务器正在运行:

Hapi.js server running at http://10cc6b467731:3000

However, when I try to navigate to http://10cc6b467731:3000 in my browser I am unable to access the app. 但是,当我尝试在浏览器中导航到http://10cc6b467731:3000时,无法访问该应用程序。

My initial thought was that the port forwarding is messed up. 我最初的想法是端口转发混乱。 I went into my VirtualBox configs for this VM, but it still does not work: 我进入了此虚拟机的VirtualBox配置,但仍然无法正常工作: 在此处输入图片说明

I also included port forwarding in my docker-compose.yml file, but to no avail: 我还在docker-compose.yml文件中包含了端口转发功能,但无济于事:

chat:
  build: .
  ports:
    - '3000:3000'
  volumes:
    - .:/home/app/chat
    - /home/app/chat/node_modules

Now I am questioning if this is even a port forwarding issue at all. 现在,我在质疑这甚至根本不是端口转发问题。 I am new to Docker and configuring VM's so I am not sure what direction to go in to continue troubleshooting this. 我是Docker的新用户,并且正在配置VM,所以我不确定该继续前进的方向。 What steps can I perform to confirm this is a port forwarding issue? 我可以执行哪些步骤来确认这是端口转发问题?

You need to allow all IPs in node.js server code 您需要在node.js服务器代码中允许所有IP

add code like listen(3000, "0.0.0.0"); 添加类似listen(3000, "0.0.0.0"); in your node server.js 在您的节点server.js中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 保持Nodejs服务器在Azure虚拟机上运行 - keep nodejs server on azure VM running NodeJS/nextJS 应用程序未在 windows 机器上运行 - NodeJS/nextJS app is not running on windows machine NodeJS / Express无法连接到docker中运行的mongodb - NodeJS / Express cannot connect to mongodb running in docker 如何在Azure虚拟机上配置并连接到正在运行的NodeJS Webapp - How to configure and connect to a running NodeJS webapp on Azure virtual machine 本地网络上的其他人如何在我的机器上运行时访问我的 NodeJS 应用程序? - How could others, on a local network, access my NodeJS app while it's running on my machine? 在 docker 容器上运行 nodejs 应用程序会给出“错误:找不到模块'/usr/src/app/nodemon'” - Running a nodejs app on a docker container gives “ Error: Cannot find module '/usr/src/app/nodemon' ” MongoError:无法连接到服务器 [<docker-machine> :<port> ] 在第一次连接 - MongoError: failed to connect to server [<docker-machine>:<port>] on first connect 如何访问在同一个 Pod 中运行的 NodeJS 服务器? - How to access NodeJS server that is running in the same pod? 无法在虚拟机中的Docker容器中运行的到达节点服务器 - Cant reach node server running in docker container in vm tinylr / nodejs-如何访问当前运行的服务器 - tinylr/nodejs - how to access the currently running server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM