[英]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.