skip to Main Content

I have docker installed on windows 11
I can’t ping the host machine from inside any container
Telnet from any container doesn’t connect to any port on the host machine

This was working fine for over a year now, but suddenly it stopped, I’m not sure if it was an update that caused this or what.

To keep it simple, I created a new ubuntu container with bridged network

1a6070345c6e ubuntu_default bridge local

I disabled the firewall on the host machine

I then tried to ping the host machine, with no success

> root@350629447ec5:/# ping 192.168.100.100
> PING 192.168.100.100 (192.168.100.100) 56(84) bytes of data.
> ^C
> 192.168.100.100 ping statistics --- 131 packets transmitted, 0 received, 100% packet loss, time 135229ms

Then I tried with telnet:

> root@350629447ec5:/# telnet 192.168.100.100 80
> Trying 192.168.100.100...

As I mentioned, this was working before, how can I debug and solve this issue?

2

Answers


  1. First of all I will try to do

    docker ps
    

    To show if the port is open on the container should look something like this

    CONTAINER ID   IMAGE            COMMAND         STATUS         PORTS     NAMES
    1a6070345c6e   ubuntu_default   "/bin/bash"   Up 6 seconds     80:80     ubuntu_default
    

    If this commands doesn’t show the port open try something like this

    docker run -p PORTINYOURMACHINE:PORTINCONTAINER -d IMAGE
    

    If that is not the case try to run the container in host mode instead of bridge to see difference

    Also verify that your IP is similar(same octets) to what are you trying to ping check on windows with

    ipconfig
    
    Login or Signup to reply.
  2. To access the host from a container, the recommended way is to add --add-host=host.docker.internal:host-gateway to your docker run command. Then you can use the hostname host.docker.internal to access it.

    Like this

    docker run --rm -it --add-host=host.docker.internal:host-gateway debian
    

    and then inside the container you can

    ping host.docker.internal
    

    (you need to install ping first if you use the debian image in my example)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search