Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git clone can not reach host inside docker container

I met this problem long time ago and can not solve it at all. Can anyone give me some help?

I created a docker container, and then inside docker, I want to clone an internal git repository:

git clone [email protected]:ngcsc/ngcsc.git

And I got this error:

ssh: connect to host git.xxx.net port 22: No route to host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

If I use curl https://git.xxx.net, I also met error:

curl: (7) Failed connect to git.xxx.net:443; No route to host

I can curl other https website, such as curl https://www.google.com

I don't know why some internal website can be reached inside docker, some not. Any suggestions are appreciated

like image 852
user3006967 Avatar asked Jun 29 '26 12:06

user3006967


1 Answers

I think since you are using the ssh url for git clone, you would have generate a ssh key and register the same on the git portal.

GitHub ssh registration

Then you would have to include the ssh key inside the docker container and do ssh-add keyfile

Hope this solves your problem

like image 128
unnik Avatar answered Jul 01 '26 01:07

unnik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!