Open afshin-hoseini opened 3 years ago
I'm glad you like it :D
I had the same issue. Because of some restrictions enforced by docker, you can't access the host IP from inside the container. Using --net=host
is one option. I do not recommend it; because it binds the whole host network to the container.
I'm using a different approach. A container can reach the host via the 172.17.0.1
IP (gateway of the docker's default network). Rather than using the host's IP, you can use it to connect to the host. I double-checked this solution. It is working as expected. Something like:
username@hostname$ ssh root@172.17.0.1
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Dec 20 21:39:23 2020 from 172.17.0.3
username@hostname$
Holy Moly... Yupe it works, but still I have issue for other domains and containers I have on host machine. But anyway, that would sufficient for now. If you found any solution around it, I'll appreciate let me know about it.
Thanks.
First of all, I really appreciate your effort. This image is what I really was looking for. I just faced an issue with connecting to host machine's internal network when my client is connected to OCServ container. Perhaps the container cannot access the host machine's network.
I don't know if linking the container to host network using
--net=host
suitable. Do you have any idea around it?