skip to Main Content

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

3

Answers


  1. Chosen as BEST ANSWER

    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


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

    docker exec -ti <container_id> /bin/bash -c "hostname -I"
    
    Login or Signup to reply.
  3. You can get the IP address of containers from this command:

    docker inspect -f "{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}" <container_name_or_id>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search