centos7使用docker部署gitlab-ce-zh應用

轉載來自 https://www.cnblogs.com/xuezhigu/p/6555895.html

 

1.國內拉取鏡像比較慢,所以這裏採用DaoCloud源。

# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://43049fd0.m.daocloud.io

  

2.拉取鏡像

# docker pull twang2218/gitlab-ce-zh

  

3.啓動容器

# docker run --detach \
    --hostname git.xiaohuruwei.com \
    --publish 8443:443 --publish 8080:80 --publish 2222:22 \
    --name gitlab \
    --restart always \
    --volume /srv/gitlab/config:/etc/gitlab \
    --volume /srv/gitlab/gitlab/logs:/var/log/gitlab \
    --volume /srv/gitlab/gitlab/data:/var/opt/gitlab \
    twang2218/gitlab-ce-zh:latest

  

4.命令參數解釋

--hostname
指定容器中綁定的域名,會在創建鏡像倉庫的時候使用到,這裏綁定git.xiaohuruwei.com
 
--publish
端口映射,冒號前面是宿主機端口,後面是容器expose出的端口
 
--volume
volume 映射,冒號前面是宿主機的一個文件路徑,後面是容器中的文件路徑

  

 

注:首次打開時,需要設置用密碼。默認用戶名爲root。

 

ssh方式訪問

因爲是使用docker部署的,通過ssh方式(比如git clone [email protected])訪問會有兩層認證:

一層是freelancer服務器的認證
另一層是gitlab的認證。
後者需要使用ssh-key
前者可能需要ssh本身的反向代理(現在使用的nginx不支持除http,https以外的反向代理),

現在發現使用端口轉發的形式比較困難,但是可以改變默認的gitlab的ssh端口爲非標準端口:
直接修改gitlab配置文件中的變量:

然後重新啓動docker容器,就可以在web界面中看到相應的ssh地址發生了改變:

ssh://[email protected]:2222/root/test.git 然後就直接可以繼續使用git clone來繼續操作了

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章