[英]No response from server running in Docker container within LAN
I'm not sure if this is a networking issue, or a Docker issue, but I'm having a difficult time getting a response from a server on a separate machine in my LAN that is running a nodejs server on port 3000 in a Docker container. 我不确定这是网络问题还是Docker问题,但是我很难从局域网中另一台计算机上的服务器获得响应,该服务器在Docker的3000端口上运行Node.js服务器容器。 I'm using a Mac computer as a client, and a Linux computer as a server. 我使用Mac计算机作为客户端,使用Linux计算机作为服务器。 These are the steps I've taken : 这些是我已采取的步骤:
Testing connection to separate computer on LAN using <name of computer>.local:<port>
使用<name of computer>.local:<port>
在LAN上测试与另一台计算机的连接
curl <name of linux computer>.local:3000
在Mac(客户端)计算机上,运行curl <name of linux computer>.local:3000
Testing connection to server on localhost while running inside of a Docker container 在Docker容器中运行时测试与本地主机上服务器的连接
docker run -p 127.0.0.1:3000:3000 <name of image>
使用命令docker run -p 127.0.0.1:3000:3000 <name of image>
在容器内部的Linux计算机上运行服务器 curl localhost:3000
在Linux机器上,运行curl localhost:3000
Testing connection to separate computer while running server in Docker container 在Docker容器中运行服务器时测试与单独计算机的连接
docker run -p 127.0.0.1:3000:3000 <name of image>
使用命令docker run -p 127.0.0.1:3000:3000 <name of image>
在容器内部的Linux计算机上运行服务器 curl <name of linux computer>.local:3000
在mac机上运行curl <name of linux computer>.local:3000
The container will not be accessable external to the Linux host when listening on 127.0.0.1
/ localhost
. 在127.0.0.1
/ localhost
上侦听时,将无法在Linux主机外部访问该容器。
To bind to all available interfaces use: 要绑定到所有可用接口,请使用:
docker run -p 3000:3000 <image>
Or specify the address of a publicly available interface from ip address show
或从ip address show
指定公共可用接口的ip address show
docker run -p <public_ip>:3000:3000 <image>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.