Home > Net >  How to get a Docker container's IP address from the Windows host
How to get a Docker container's IP address from the Windows host

Time:06-30

How do I detect the IP of a docker container running on Windows host with WSL?

I can see docker container is running:

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

CodePudding user response:

Open Windows command line and use ipconfig

ipconfig

Find Ethernet-Adapter vEthernet (WSL) (Or similar) there you will see IP4 and IP6.

Screenshot is from a german Windows but I am sure other version look pretty much the same.

enter image description here

CodePudding user response:

You can try launching "hostname -I" command inside the running container. For example:

docker exec -ti <container_id> /bin/bash -c "hostname -I"

CodePudding user response:

You can get the IP address of containers from this command:

docker inspect -f "{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}" <container_name_or_id>
  • Related