如何通过 SSH 访问远程计算机上 Docker 容器上托管的网页?
我有一个网页托管在远程计算机上的 Docker 容器中的 0.0.0.0:5555
上(通过某个 IP 地址,比如说 123.4.5.6
),该网页监听外部端口 8000
上的连接。
如何通过端口 5555
在我的本地计算机上访问此网页?
到目前为止我所拥有的是:
在我的本地计算机上:
ssh -p 8000 -L 5555:0.0.0.0:5555 [电子邮件受保护]
在远程计算机上: docker run -it --rm -p 5555:5555 docker_src
但是,它表示 0.0.0.0:5555
的绑定失败,因为端口已分配。
我应该如何连接到 0.0.0.0:5555
上托管的远程页面
I have a webpage hosted on 0.0.0.0:5555
in a Docker container on a remote computer (through some IP address, let's say 123.4.5.6
), which listens to external connections on port 8000
.
How do I access to this webpage on my local machine through port 5555
?
What I have so far is:
on my local machine :
ssh -p 8000 -L 5555:0.0.0.0:5555 [email protected]
on the remote machine :
docker run -it --rm -p 5555:5555 docker_src
However, it says the bind for 0.0.0.0:5555
failed because the port is already allocated.
How should I connect to the remote page hosted on 0.0.0.0:5555
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果由于端口 5555 已被占用而导致运行命令失败,则需要停止侦听该端口的内容,或者在发布容器端口时使用其他端口。
然后您还需要在隧道命令中使用 5556。
If the run command fails because port 5555 is already taken, you need to stop what is listening on this port or use a different port when you publish the container port.
Then you also need to use 5556 in your tunnel command.