CentOS 7.5 x64
Dokcer-ce:18.03
Gitlab:10.8.1-ce.0
1) docker pull gitlab/gitlab-ce 获取镜像
2)按照 官方 https://docs.gitlab.com/omnibus/docker/README.html
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
结果尴尬了
docker: Error response from daemon:
driver failed programming external connectivity on endpoint gitlab3
(9285fe78ca075cd23dcd42298dd2f3cd58bbe24c3ddaaa71b97ea41cd52e97d4):
Error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use.
既然本地 22 端口被占用了,换个 2222,结果 OK 了。
3)配置 external_url 和 邮件服务
sudo docker exec -it gitlab vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.29.10:80'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxx@htd.cn"
gitlab_rails['smtp_password'] = "xxxxpasswd"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = "xxxx@htd.cn"
gitlab_rails['smtp_domain'] = "exmail.qq.com"
配置之后重启,
sudo docker restart gitlab
无限重启中,等了半天也没好,肯定是容器有问题,去掉 --restart always ,再测试下,然后查看日志
sudo docker logs gitlab
一看是权限的问题,还有 root 用户没有的权限么,
还真有 SELinux ?, 什么鬼,Centos 7.x 默认是 开启的,用不上,关了吧
vim /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled
然后 reboot 重启
[root@localhost ~]# sestatus
SELinux status: disabled
[root@localhost ~]#
显示禁用了
4) 修改端口
由于服务有限,80 端口,我还要留着给 Nginx 呢,按照官方配置
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 \
gitlab/gitlab-ce:latest
external_url "http://192.168.29.10:8929"
gitlab_rails['gitlab_shell_ssh_port'] = 2289
启动了无法访问,难道 external_url 不能配置端口么?
https://www.cnblogs.com/int32bit/p/5310382.html 博主也遇到这个问题
改为 external_url "http://gitlab.example.com",
http://gitlab.example.com:8929 OK 了,以为大功告成了,添加个用户试试, 链接 端口号丢了
如何是好,修改 gitlab.rb 的 Nginx 端口号
nginx['redirect_http_to_https_port'] = 8929
重启
sudo docker restart gitlab
还是访问不了,晕菜了。。。。。
忘记 原来 创建容器的是 内部端口指定的是 80, 重启当然不管用啊
重现构建,大功告成
sudo docker run --detach \
--hostname gitlab2 \
--env GITLAB_OMNIBUS_CONFIG="external_url 'http://192.168.29.10:83/';" \
--publish 83:83 --publish 2223:2223 \
--name gitlab2 \
--volume /srv/gitlab2/config:/etc/gitlab \
--volume /srv/gitlab2/logs:/var/log/gitlab \
--volume /srv/gitlab2/data:/var/opt/gitlab \
gitlab/gitlab-ce:rc
GitLab 安装内存那叫一个大,什么都没有,开了两个镜像,占用了10几G 的内存
[root@localhost ~]# free -h
total used free shared buff/cache available
Mem: 31G 16G 12G 29M 1.3G 13G
Swap: 15G 0B 15G
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gitea/gitea latest ec1e11c59922 35 hours ago 75.2MB
gitlab/gitlab-ce rc 6d883eceea3e 2 days ago 1.34GB
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7f5804a8eafe gitlab/gitlab-ce:rc "/assets/wrapper" 10 minutes ago Up 10 minutes (healthy) 22/tcp, 80/tcp, 0.0.0.0:83->83/tcp, 443/tcp, 0.0.0.0:2223->2223/tcp gitlab2
83b9a7380a09 gitlab/gitlab-ce:rc "/assets/wrapper" About an hour ago Up About an hour (healthy) 0.0.0.0:80->80/tcp, 443/tcp, 0.0.0.0:2222->22/tcp gitlab
[root@localhost ~]# docker stop gitlab
gitlab
[root@localhost ~]# docker stop gitlab2
gitlab2
[root@localhost ~]# free -h
total used free shared buff/cache available
Mem: 31G 1.1G 28G 9.2M 1.2G 29G
Swap: 15G 0B 15G
坑只能入一次,希望后面的人,不要学我
╭~~~╮
(o~.~o)