Coder Guy
Coder Guy

Reputation: 31

Problem in Ping or SSH connect to docker container

I am new to docker. I installed docker on Windows 10. Also, I have installed SSH on my win.

I have a pylucene docker container. When I check the status of my docker container, it is Up.

PS C:\Windows\system32> docker ps -a
CONTAINER ID   IMAGE            COMMAND       CREATED       STATUS        PORTS     NAMES
d70d6f0ed7ab   coady/pylucene   "/bin/bash"   4 weeks ago   Up 3 hours              amazing_dubinsky

Also, I have no problem with executing it and working with its shell.

PS C:\Windows\system32> docker exec -it d70d6f0ed7ab /bin/bash
root@d70d6f0ed7ab:/usr/src# python
Python 3.9.2 (default, Mar 31 2021, 12:13:11)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lucene
>>> print(lucene.VERSION)
8.8.1
>>>                                                                                                                           

but when I found its IP and try to ping this docker container from my win, the result is just timeout!

PS C:\Windows\system32> docker inspect -f "{{ .NetworkSettings.IPAddress }}" d70d6f0ed7ab                               
172.17.0.3
PS C:\Windows\system32> ping 172.17.0.3                                                                                 
Pinging 172.17.0.3 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 172.17.0.3:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
PS C:\Windows\system32>   

Also SSH connect to this container fails,

PS C:\Windows\system32> ssh [email protected]                                                                             
ssh: connect to host 172.17.0.3 port 22: Connection timed out
PS C:\Windows\system32>   

Upvotes: 1

Views: 1165

Answers (1)

VonC
VonC

Reputation: 1323145

The coady/pylucene image is based on python:latest

And... debian 10 does not have openssh-server installed/active by default.

Plus, as mentioned here:

Docker Desktop for Windows can’t route traffic to Linux containers.
However, you can ping the Windows containers.

In other words, those "problems" you are experiencing are perfectly expected.

Upvotes: 0

Related Questions