[英]How to get a Docker container's IP address from the Windows host
How do I detect the IP of a docker container running on Windows host with WSL?如何使用 WSL 检测在 Windows 主机上运行的 docker 容器的 IP?
I can see docker container is running:我可以看到 docker 容器正在运行:
juergen@DESKTOP4WIN10:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
74f26c50a729 jschulze71/apache2 "sh -c '. /etc/apach…" 24 seconds ago Up 23 seconds 0.0.0.0:8080->80/tcp elegant_jepsen
You can try launching "hostname -I" command inside the running container.您可以尝试在正在运行的容器中启动“hostname -I”命令。 For example:
例如:
docker exec -ti <container_id> /bin/bash -c "hostname -I"
您可以通过以下命令获取容器的 IP 地址:
docker inspect -f "{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}" <container_name_or_id>
Open Windows command line and use ipconfig打开 Windows 命令行并使用ipconfig
ipconfig
Find Ethernet-Adapter vEthernet (WSL) (Or similar) there you will see IP4 and IP6.在那里找到以太网适配器 vEthernet (WSL) (或类似的),您将看到 IP4 和 IP6。
Screenshot is from a german Windows but I am sure other version look pretty much the same.屏幕截图来自德语 Windows,但我确信其他版本看起来几乎相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.