如何通过 SSH 访问远程计算机上 Docker 容器上托管的网页?

发布于 2025-01-11 23:46:30 字数 587 浏览 4 评论 0原文

我有一个网页托管在远程计算机上的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恋你朝朝暮暮 2025-01-18 23:46:30

如果由于端口 5555 已被占用而导致运行命令失败,则需要停止侦听该端口的内容,或者在发布容器端口时使用其他端口。

docker run -it --rm --publish 5556:5555 docker_src

然后您还需要在隧道命令中使用 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.

docker run -it --rm --publish 5556:5555 docker_src

Then you also need to use 5556 in your tunnel command.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文