如何访问监听 0.0.0.0:8000 的 docker 容器
我是 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如你在这里看到的:
Docker 正在将容器的端口 8000 映射到主机的端口 8000。因此,要向容器发送请求,您需要从主机(在您的情况下为 Windows)向 localhost:8000 发出请求。
As you can see here:
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).您可以使用端口 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.