docker gitlab 如何git clone?
問題描述
它給的SSH和http地址是這樣的:
git@6b30d4a6a162:compontent/gitlab-test-component.githttp://6b30d4a6a162/compontent/gitlab-test-component.git
6b30d4a6a162是gitlab的container Info的ID的一部分:
6b30d4a6a16279326a135ee2c7bf7b20094b3199a299ac6345735dd3
我通過上面兩個地址都無法git clone。
因為我用virtualbox簡單的做了一下端口映射,所以我嘗試用
git clone http://localhost:8100/compontent/gitlab-test-component
但會報錯:500
有知道的嗎?
另外想問一下,ssh-key是不是只要生成一次就行了,可以到處放github、gitlab,或者其他地方的,都是同一份?
問題解答
回答1:因為host的22端口已經被占用了
在docker run 的時候將container的22端口映射到host的其他端口如2222
docker run gitlab -p 2222:22
需要在 gitlab 的配置文件里指定url
# 修改 /etc/gitlab/gitlab.rb 文件第一行external_url ’http://192.168.1.23/’
這樣在項目倉庫里顯示出來的就是
[email protected]:2222/shadowsocks/shadowsocks.git
然后就能使用git了
git clone [email protected]:2222/shadowsocks/shadowsocks.git
這時候需要在開發機器上配置 .ssh/config 文件,才能正常使用
以下是一個使用 docker 運行gitlab的例子
docker run --name=’gitlabend’ --link gitlab_mysql:mysql --link gitlab_redis:redisio -e ’GITLAB_PORT=10080’ -e ’GITLAB_SSH_PORT=10022’ -p 10022:22 -p 10080:80 -e ’GITLAB_HOST=xxxx’ -e ’[email protected]’ -e ’SMTP_ENABLED=true’ -e ’SMTP_DOMAIN=qq.com’ -e ’SMTP_HOST=smtp.exmail.qq.com’ -e ’SMTP_PORT=25’ -e ’SMTP_STARTTLS=false’ -e ’[email protected]’ -e ’SMTP_PASS=password’ -e ’SMTP_AUTHENTICATION=login’ -v /opt/gitlab/data:/home/git/data -v /opt/gitlab/log:/var/log/gitlab sameersbn/gitlab:latest回答2:
用法有問題吧,肯定不是用docker的container name 做域名啊,你要綁一個域名或者用ip+端口訪問才能clone的。
回答3:@Tairy ,話說我上面不是用了域名+端口嗎?
就是localhost:8100啊,但它會報500錯誤。。
你能說一下你的綁定是怎么綁嗎?
相關文章:
1. dockerfile - 我用docker build的時候出現下邊問題 麻煩幫我看一下2. docker不顯示端口映射呢?3. android - viewpager問題PagerTabStrip樣式4. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?5. javascript - CSS圖片輪播顯示問題6. javascript - vue-router怎么不能實現跳轉呢7. python 字符串匹配問題8. angular.js - angular內容過長展開收起效果9. javascript - 這里的這個函數是干嘛用的?10. docker綁定了nginx端口 外部訪問不到
