我已经成功运行了gitlab docker image,但是无法使用git客户端来访问它。
(1)我发现有3个IP地址:
a)主机IP:10.137.20.113;
b)附加gitlab运行容器,显示其IP:172.17.0.13;
c)登录网页,它显示项目地址:ssh: git@192.168.59.103:root/test.git。
为什么会有IP地址(192.168.59.103)?
(2)我在root中添加了SSH用户gitlab键,但是无法使用ssh -p 2222 10.137.20.113命令访问服务器。
如何使用git client访问gitlab?
请您参考如下方法:
192.168.59.103是boot2docker ip的典型代表,它是VirtualBox计算机的IP,该计算机托管运行容器的Tiny核心Linux(具有172.17.0.13的容器)
如果要从客户端访问任何端口,则需要确保:
docker run -p 2222:22 -p 80:80 -p 443:443 ... boot2docker-vm”的VirtualBox网络定义中重定向:例如:
boot2docker stop
VBoxManage.exe controlvm "boot2docker-vm" natpf1 "udp-port80,udp,,80,,80";
VBoxManage.exe controlvm "boot2docker-vm" natpf1 "udp-port80,udp,,443,,443";
(与443、2222相同)应该已经导出)
否则,客户端(VirtualBox外部)在访问192.168.59.103时将无法看到这些端口。
在OP情况下,不需要192.168.59.103。 RedHat服务器的IP已足够(因为它直接托管docker服务)。
ssh -p 2222 10.137.20.113仅适用于正确的用户(git)
ssh -p 2222 git@10.137.20.113
并且仅当 public ssh key has been registered on the server时。
OP报告 in the comments错误:
git-upload-pack '2222:root/test.git'
I fix the problem in 2 steps:
- add Port
2222in~/.ssh/config- Use
git clone git@10.137.20.113:root/test.git
您可以在“
~/.ssh/config using ssh failed in Windows due to permission issue”中看到更完整的
git clone示例。
After testing, this also work:
git clone ssh://git@10.137.20.113:2222/root/test.git
(因此使用“
/”而不是“
:”)




