如何访问监听 0.0.0.0:8000 的 docker 容器

发布于 2025-01-10 21:09:17 字数 455 浏览 3 评论 0原文

我是 Docker 新手,正在尝试使用适用于 Windows 的 Docker Desktop 运行开源 Django 应用程序。

命令 docker container ls 显示应用程序正在运行,并且服务正在侦听端口 0.0.0.0:8000。

我应该在 Windows 主机上使用什么 IP 地址来访问此服务?我很感激你的帮助。

docker container ls

...
1f2c70d56d48   saleor-platform_api          "python manage.py ru…"   23 minutes ago   Up 23 minutes   0.0.0.0:8000->8000/tcp
                                                               saleor-platform-api-1
...

I am new to Docker and trying to run an open-source Django application with Docker Desktop for Windows.

Command docker container ls shows the application is running, and the service is listening on port 0.0.0.0:8000.

What IP address should I use on the Windows host to access this service? I appreciate your help.

docker container ls

...
1f2c70d56d48   saleor-platform_api          "python manage.py ru…"   23 minutes ago   Up 23 minutes   0.0.0.0:8000->8000/tcp
                                                               saleor-platform-api-1
...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

鸠魁 2025-01-17 21:09:17

正如你在这里看到的:

0.0.0.0:8000->8000

Docker 正在将容器的端口 8000 映射到主机的端口 8000。因此,要向容器发送请求,您需要从主机(在您的情况下为 Windows)向 localhost:8000 发出请求。

As you can see here:

0.0.0.0:8000->8000

Docker is mapping the port 8000 of your container to the port 8000 of the host. Therefore, to send a request to the container, you need to make a request to localhost:8000 from the host (Windows in your case).

亢潮 2025-01-17 21:09:17

您可以使用端口 8000 并将主机用作 localhost、127.0.0.1 或 0.0.0.0。

You would use port 8000 and host as either localhost or 127.0.0.1 or 0.0.0.0.

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