# ERROR ## 问题一:GitLab容器一直重启 使用`docker logs`命令查询 ``` $ docker log CONTAINER_ID ... ... System Info: ------------ chef_version=14.13.11 platform=ubuntu platform_version=16.04 ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] program_name=/opt/gitlab/embedded/bin/chef-client executable=/opt/gitlab/embedded/bin/chef-client Running handlers: There was an error running gitlab-ctl reconfigure: /etc/gitlab/gitlab.rb:1: unexpected fraction part after numeric literal external_url = 192.168.0.144:7002 ^~~~~~~ /etc/gitlab/gitlab.rb:1: syntax error, unexpected tINTEGER, expecting end-of-input external_url = 192.168.0.144:7002 ^~~ Running handlers complete Chef Client failed. 0 resources updated in 01 seconds ``` 发现是`external_url`配置失误导致。解决方法如下: 1. 停止`gitlab`容器 2. 修改配置文件(在主机中)`/srv/gitlab/config/gitlab.rb` 3. 重新启动容器 ## 问题二:GitLab导致8080端口冲突 ### 问题复现 安装完`GitLab`后,修改配置文件`/etc/gitlab/gitlab.rb` ``` ##external_url 'http://gitlab.example.com' external_url 'http://localhost:8800' ``` 本以为这样就能修改`GitLab`端口号为`8800`了,没想到再次登录`8080`仍旧出现了`GitLab`页面  ### 问题解析 查询哪个程序监听了`8080`端口 ``` # netstat -lnp | grep 8080 tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 26436/config.ru ``` 查询相应的进程 ``` # netstat -lnp | grep 26436 tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 26436/config.ru unix 2 [ ACC ] STREAM LISTENING 343538 26436/config.ru /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket ``` 仍然是`GitLab`在监听`8080`端口,参考[gitlab 8.13 80 8080端口冲突问题](https://blog.csdn.net/vbaspdelphi/article/details/52979836),查看配置文件`unicorn.rb` ``` # This file is managed by gitlab-ctl. Manual changes will be # erased! To change the contents below, edit /etc/gitlab/gitlab.rb # and run `sudo gitlab-ctl reconfigure`. # What ports/sockets to listen on, and what options for them. listen "127.0.0.1:8080", :tcp_nopush => true ``` 默认情况下`unicorn`同样监听`8080`端口,查询`/etc/gitlab/gitlab.rb`中相应的设置 ``` # cat gitlab.rb | grep unicorn #unicorn['port'] = 8800 ``` ### 解决方案 需要在`gitlab.rb`上同时修改`unicorn`监听端口号,修改配置文件`/etc/gitlab/gitlab.rb`如下 ``` ##external_url 'http://gitlab.example.com' external_url 'http://localhost:8800' unicorn['port'] = 8801 ``` 重新启动`GitLab` ``` # gitlab-ctl reconfigure # gitlab-ctl restart ``` 查询配置文件`/var/opt/gitlab/gitlab-rails/etc/unicorn.rb` ``` # cat unicorn.rb | grep listen # What ports/sockets to listen on, and what options for them. listen "127.0.0.1:8801", :tcp_nopush => true ``` 测试端口号 ``` $ curl localhost:8080 curl: (7) Failed to connect to localhost port 8080: Connection refused $ curl localhost:8800
... ... # curl localhost:8801 You are being redirected. ``` ## 问题三: [GitLab][Webhook]不允许本地连接 在`gitlab`仓库中设置`Webhook`,使用本地连接出现如下错误: ``` Url is blocked: Requests to the local network are not allowed ``` 参考:[gitlab使用webhook向jenkins发送请求,报错 Requests to the local network are not allowed](https://blog.csdn.net/xukangkang1hao/article/details/80756085) 登录`root`账户,点击`Configure Gitlab`选项  进入`Settings -> Network`,展开`Outbound requests`,选中`Allow requests to the local network from web hooks and services`  ## 问题四:GitLab: You are not allowed to force push code to a protected branch on this project 强制上传代码到`Gitlab`仓库的`dev`分支出错,提示如下: ``` GitLab: You are not allowed to force push code to a protected branch on this project ``` 参考:[解决 GitLab: You are not allowed to force push code to a protected branch on this project问题](https://blog.csdn.net/mqdxiaoxiao/article/details/95794053) 是由于分支保护的原因,需要进入仓库`setting -> Repository -> Protected Branches`  允许`dev`分支能够强制推送 ## 问题五:unicorn出错 ### 问题描述 通过`docker`部署`gitlab`一段时间后,突然出现`502`错误 查看容器状态,显示不健康 ``` CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 89481faa2ed1 gitlab/gitlab-ce:latest "/assets/wrapper" 2 weeks ago Up 7 hours (unhealthy) ``` 浏览容器日志,发现如下错误: ``` ==> /var/log/gitlab/unicorn/unicorn_stdout.log <== bundler: failed to load command: unicorn (/opt/gitlab/embedded/bin/unicorn) ==> /var/log/gitlab/unicorn/unicorn_stderr.log <== ArgumentError: Already running on PID:460 (or pid=/opt/gitlab/var/unicorn/unicorn.pid is stale) /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=' /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `