冰醇柠檬 發表於 2024-6-29 00:00:00

centos7使用docker部署gitlab-ce-zh应用详解

<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>1.国内拉取镜像比较慢,所以这里采用DaoCloud源。</strong></p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:bash;">#&nbsp;curl&nbsp;-sSL&nbsp;https://get.daocloud.io/daotools/set_mirror.sh&nbsp;|&nbsp;sh&nbsp;-s&nbsp;http://43049fd0.m.daocloud.io</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>2.拉取镜像</strong></p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:bash;">#&nbsp;docker&nbsp;pull&nbsp;twang2218/gitlab-ce-zh</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>3.启动容器</strong></p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:bash;">docker&nbsp;run&nbsp;--detach&nbsp;\
&nbsp;&nbsp;&nbsp;&nbsp;--hostname&nbsp;git.xiaohuruwei.com&nbsp;\
&nbsp;&nbsp;&nbsp;&nbsp;--publish&nbsp;8443:443&nbsp;--publish&nbsp;8080:80&nbsp;--publish&nbsp;2222:22&nbsp;\
&nbsp;&nbsp;&nbsp;&nbsp;--name&nbsp;gitlab&nbsp;\
&nbsp;&nbsp;&nbsp;&nbsp;--restart&nbsp;always&nbsp;\
&nbsp;&nbsp;&nbsp;&nbsp;--volume&nbsp;/srv/gitlab/config:/etc/gitlab&nbsp;\
&nbsp;&nbsp;&nbsp;&nbsp;--volume&nbsp;/srv/gitlab/gitlab/logs:/var/log/gitlab&nbsp;\
&nbsp;&nbsp;&nbsp;&nbsp;--volume&nbsp;/srv/gitlab/gitlab/data:/var/opt/gitlab&nbsp;\
&nbsp;&nbsp;&nbsp;&nbsp;twang2218/gitlab-ce-zh:latest</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>4.命令参数解释</strong></p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:bash;">--hostname
指定容器中绑定的域名,会在创建镜像仓库的时候使用到,这里绑定git.xiaohuruwei.com
&nbsp;
--publish
端口映射,冒号前面是宿主机端口,后面是容器expose出的端口
&nbsp;
--volume
volume&nbsp;映射,冒号前面是宿主机的一个文件路径,后面是容器中的文件路径</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>5.本地访问地址</strong></p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:bash;">git.xiaohuruwei.com</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>注:首次打开时,需要设置用密码。默认用户名为root。</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>ssh方式访问</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        因为是使用docker部署的,通过ssh方式(比如git clone git@git.xiaohuruwei.com)访问会有两层认证:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        一层是freelancer服务器的认证</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        另一层是gitlab的认证。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        后者需要使用ssh-key</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        前者可能需要ssh本身的反向代理(现在使用的nginx不支持除http,https以外的反向代理),</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        现在发现使用端口转发的形式比较困难,但是可以改变默认的gitlab的ssh端口为非标准端口:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        直接修改gitlab配置文件中的变量:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:bash;">gitlab_shell_ssh_port&nbsp;=&nbsp;2222</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        然后重新启动docker容器,就可以在web界面中看到相应的ssh地址发生了改变:ssh://git@git.xiaohuruwei.com:2222/root/test.git 然后就直接可以继续使用git clone来继续操作了</p>
頁: [1]
查看完整版本: centos7使用docker部署gitlab-ce-zh应用详解