2

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 git@git.xxx.net: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

Jakuje
  • 24,773
  • 12
  • 69
  • 75
user3006967
  • 3,291
  • 10
  • 47
  • 72
  • Could be relevant here: http://stackoverflow.com/a/31328031/6309 and http://askubuntu.com/a/136414/5470 and http://blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker/ – VonC Mar 19 '16 at 07:56

2 Answers2

1

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

unnik
  • 1,123
  • 5
  • 18
  • 37
0

First, make sure you have mapped the relevant ports when you start the container, generally ssh use port 22 or 443, so you can simply map both them.

docker run -it -p 22:22 -p 443:443 IMAGE_ID

Second, inside the docker, you should generate an ssh key-pair and register the git portal you are using. Simply you can use command ssh-keygen to generate an new key pair.

mainframer
  • 20,411
  • 12
  • 49
  • 68