以前写过一篇关于在,centos下安装gitlab的文章,安装是非常麻烦的。不像在debian系中,源中就有,这就比较方便了。如果不想用debian系,又想很方便的使用gitlab怎么办呢?
1,安装docker
# yum install docker-io
2,下载gitlab镜像,推荐gitlab/gitlab-ce
# docker pull gitlab/gitlab-ce
3,创建目录
# mkdir -p /srv/gitlab/config # mkdir -p /srv/gitlab/logs # mkdir -p /srv/gitlab/data
config文件夹,存放了,gitlab的公钥文件
logs文件夹,存放了,pgsql,Nginx,ssh,gitlab等的log
data文件夹,存放了gitlab的版本库,Nginx,pgsql,redis的配置文件,数据等。
4,创建容器
# docker run --detach \ --hostname gitlab.mytest.com\ --publish 10443:443 --publish 10080:80 --publish 10022:22 \ --name gitlab \ --restart always \ --volume /srv/gitlab/config:/etc/gitlab \ --volume /srv/gitlab/logs:/var/log/gitlab \ --volume /srv/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest
5,查看是否启动成功
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1d44d8f9db5c gitlab/gitlab-ce:latest "/assets/wrapper" About an hour ago Up About an hour 0.0.0.0:10022->22/tcp,0.0.0.0:10080->80/tcp,0.0.0.0:10443->443/tcp gitlab 889155f5092b centos "/bin/bash" 2 days ago Up 3 hours cen1
6,配置一下本的的hosts
# cat /etc/hosts 192.168.5.213 gitlab.mytest.com //添加
如果是公网IP,就不用改hosts了。
这样就可以访问了。看下图
怎么创建代码库就不说了,进去点几下就好了。
7,创建公钥,私钥
# ssh-keygen //生成 Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): gtest Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in gtest. Your public key has been saved in gtest.pub. The key fingerprint is: 5b:15:75:85:5c:e5:94:32:c2:c3:8b:39:dc:a5:25:f6 root@localhost.localdomain The key's randomart image is: +--[ RSA 2048]----+ | o .o.oX| | B *o= | | . = @ o .| | = = E | | S o | | o | | . | | | | | +-----------------+
登录到gitlab后台,打开公钥文件,把里面的内容COPY到gitlab。
8,配置本地ssh config
# vim /root/.ssh/config //添加以下内容 Host gitlab.mytest.com Hostname gitlab.mytest.com User gtest IdentityFile /root/gtest //私钥路径 port 10022 //这个一定要注意,不是22端口,是上面配置的,容器外端口--publish 10022:22
看一下,效果图
原文链接:https://www.f2er.com/docker/447303.html