啥年月了还用svn,日了狗一样难受。
开搞!
docker是最好的容器,直接docker装gitlab。
学新玩意不去官网不是人:
https://docs.gitlab.com/omnibus/docker/#expose-gitlab-on-different-ports
docker pull gitlab/gitlab-ce
sudo docker run --detach \ --hostname gitlab.example.com \ --publish 443:443 --publish 80:80 --publish 22: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
官网上这样说,可是他么的他报错了真的报错了:
cp: cannot create regular file '/etc/gitlab/gitlab.rb': Permission denied 。他说:挂载的本地目录在容器中没有执行权限
解决方案:加权限 --privileged=true 这个很有用在我的docker文章中也有遇到没权限的情况,遇到没权限先加一下试试。
我试了试,确实成功了。但是我想改端口!那么官老爷又说了:
For example, to expose the web interface on port 8929
, and the SSH service on port 2289
, use the following docker run
command:
sudo docker run --detach \ --hostname gitlab.example.com \ --publish 8929:80 --publish 2289: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 \
--privileged=true\ gitlab/gitlab-ce:latest
(他又忘了加权限?或者按照官老爷说的这样可以吗
If you are on SELinux then run this instead:
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab:Z \
--volume /srv/gitlab/logs:/var/log/gitlab:Z \
--volume /srv/gitlab/data:/var/opt/gitlab:Z \
gitlab/gitlab-ce:latest
)
Note: The format for publishing ports is hostPort:containerPort
. Read more in Docker’s documentation about exposing incoming ports.
(怎样设置?
官网上往回看发现:
Configure GitLab
This container uses the official Omnibus GitLab package, so all configuration is done in the unique configuration file /etc/gitlab/gitlab.rb
.
To access GitLab’s configuration file, you can start a shell session in the context of a running container. This will allow you to browse all directories and use your favorite text editor:
sudo docker exec -it gitlab /bin/bash
You can also just edit /etc/gitlab/gitlab.rb
:
sudo docker exec -it gitlab editor /etc/gitlab/gitlab.rb
Once you open /etc/gitlab/gitlab.rb
make sure to set the external_url
to point to a valid URL.
可以继续了
:)
Set
external_url
:# For HTTP
external_url "http://gitlab.example.com:8929"
or
# For HTTPS (notice the https)
external_url "https://gitlab.example.com:8929"For more information see the NGINX documentation.
Set
gitlab_shell_ssh_port
:gitlab_rails['gitlab_shell_ssh_port'] = 2289
Following the above example you will be able to reach GitLab from your web browser under :8929
and push using SSH under the port 2289
.
(我一直有个疑问,明明端口映射的是2289:22 映射的不是22吗为什么还要这样子:['gitlab_shell_ssh_port'] = 2289 ?
)然后重启:
sudo docker restart gitlab
好像这样也行:gitlab-ctl reconfigure
Note: The initialization process may take a long time. You can track this process with the command sudo docker logs -f gitlab
人家说初始化需要很长时间你可以看日志或者嗑瓜子
我是不停地贱贱的docker ps
看他一直在restaring。。。。。。盼星星盼月亮终于盼到health状态
看招:
首页点扳手可以创建用户创建群组创建项目:
我创建了一个项目然后再加了一个readme初始化项目了。
然后贫僧先用http下载项目:
新建文件夹-> git->clone->那个地址
华丽的分割线
接下来讲讲用ssh,他们说用ssh方式更嚣张
首先配置key
去git的安装目录找到usr/bin
C:\Program Files\Git\usr\bin然后地址栏输入cmd弹出大黑框执行:
ssh-keygen -t rsa -C 'xxx@xxx.com'
一路牛b加闪电按回车在用户目录下C:\Users\sht\.ssh
生成了一个id_rsa.pub这个文件:
编辑器打开复制内容然后到gatlib的ssh秘钥中添加
搞到那个大框框里面然后add成功之后去项目里面
复制新建文件夹clone直接ssh方式克隆,ohyes!
报错了:
他说我没权限,经鉴定是小王八git配置问题,我们来配置:
更改完clone:
gameover!