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 映射,冒號前面是宿主機的一個文件路徑,后面是容器中的文件路徑
5.本地訪問地址
注:首次打開時,需要設置用密碼。默認用戶名為root。
ssh方式訪問
因為是使用docker部署的,通過ssh方式(比如git clone git@git.xiaohuruwei.com)訪問會有兩層認證:
一層是freelancer服務器的認證
另一層是gitlab的認證。
后者需要使用ssh-key
前者可能需要ssh本身的反向代理(現在使用的nginx不支持除http,https以外的反向代理),
現在發現使用端口轉發的形式比較困難,但是可以改變默認的gitlab的ssh端口為非標準端口:
直接修改gitlab配置文件中的變量:
gitlab_shell_ssh_port = 2222
然后重新啟動docker容器,就可以在web界面中看到相應的ssh地址發生了改變:ssh://git@git.xiaohuruwei.com:2222/root/test.git 然后就直接可以繼續使用git clone來繼續操作了