*先决条件系统已安装Docker

1、查询GitLab镜像

docker search gitlab

 Centos7 docker安装GitLab

 

 

2、现在GitLab镜像

Centos7 docker安装GitLab

 

 

3、创建文件夹

mkdir -p /software/gitlab/config

mkdir -p /software/gitlab/logs

mkdir -p /software/gitlab/data

Centos7 docker安装GitLab

 

 

4、启动

docker run -d -p 9443:443 -p 9080:80 -p 9022:22 \
--name gitlab --restart always \
--volume /software/gitlab/config:/etc/gitlab \
--volume /software/gitlab/logs:/var/log/gitlab \
--volume /software/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:lates

 

 

5、修改配置文件   

vi gitlab/config/gitlab.rb

external_url 'http://gitlab.xxx.co'
gitlab_rails['gitlab_ssh_host'] = 'gitlab.xxx.co'
gitlab_rails['gitlab_shell_ssh_port'] = 9022

Centos7 docker安装GitLab

 

 

 

6、配置nginx

upstream gitlab {
    server xxx.xxx.xxx.xxx:9080;
}
server {
   listen 80;
   server_name gitlab.xxx.co;
   location / {
       client_max_body_size 10m;
      proxy_redirect off;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_pass http://gitlab;
    }
}

 

7、进入gitlab

首次进入要修改默认管理员密码 (管理员root)

Centos7 docker安装GitLab

 

 

优化

如果是docker  
进入容器  
  docker exec -it  gitlab /bin/bash

然后  
修改配置文件/etc/gitlab/gitlab.rb中的worker_processes:

去掉下面的注释

unicorn[‘worker_processes’] = 2  #官方推荐 CPU核心+1

还有其它优化项可改可不改

docker exec -it gitlab gitlab-ctl reconfigure

docker exec -it gitlab gitlab-ctl restart

如果不是docker直接修改后,再即可

gitlab-ctl reconfigure  
gitlab-ctl restart

 

 

后记,运行1个月后,gitlab无法上传代码,经查是磁盘满了

Centos7 docker安装GitLab

 

 

 使用以下命令,查看大文件

du -lh --max-depth=1
ls -lh

发现日志大 28个G

Centos7 docker安装GitLab

 

 

 删除日志文件

Centos7 docker安装GitLab

 

centos下删除文件后空间并未释放

Centos7 docker安装GitLab

 

 使用 lsof -n|grep deleted 查找占用文件的应用

lsof -n|grep deleted 

Centos7 docker安装GitLab

 

 重启下应用就可以了

 

 

 

相关文章:

  • 2021-09-01
  • 2021-04-23
  • 2021-05-19
  • 2021-11-11
  • 2021-06-12
  • 2021-06-14
  • 2021-05-24
猜你喜欢
  • 2021-10-04
  • 2021-08-31
  • 2021-09-24
  • 2021-11-27
  • 2022-12-23
  • 2021-12-29
  • 2021-11-05
相关资源
相似解决方案