欢迎光临,赤鹿小组
记录过程,分享经验

利用 docker 部署 gitlab

Git (读音为/gɪt/。)是一个开源的分布式版本控制系统,可以有效、高速地处理从很小到非常大的项目版本管理。「词条来源百度百科」

1、查找 gitlab 镜像

[[email protected] ] docker search gitlab

如果出现 Error response from daemon: Get https://index.docker.io/v1/search?q=gitlab&n=25: dial tcp: lookup index.docker.io: no such host 报错,重启docker服务即可,如下:

docker

2、拉取 gitlab 镜像,成功 如下图:

[[email protected] ] docker pull gitlab
Using default tag: latest
Trying to pull repository docker.io/gitlab/gitlab-ce ...
latest: Pulling from docker.io/gitlab/gitlab-ce
7e6591854262: Pull complete
089d60cb4e0a: Pull complete
9c461696bc09: Pull complete
45085432511a: Pull complete
fe923449954f: Pull complete
f7944584e435: Pull complete
47472ef1aa19: Pull complete
80d72d7c3c00: Pull complete
bb2031d6299d: Pull complete
7b6ae18e4081: Pull complete
Digest: sha256:7db74a350cc4a099c9b3fa4dcf533f7f0e9f531e44fe653c5bde26d67441cbd1
Status: Downloaded newer image for docker.io/gitlab/gitlab-ce:latest

[[email protected] ] docker images

docker

3、启动 gitlab ,如下图:

[[email protected] ] docker run -d --name gitlab --hostname 192.168.68.128 --restart always -p 8443:443 -p 8000:80 -p 2626:22 -v /data/gitlab/conf:/etc/gitlab -v /data/gitlab/logs:/var/log -v /data/gitlab/data:/var/opt/gitlab docker.io/gitlab/gitlab-ce:latest

docker

4、修改配置文件

[[email protected] ] vim /data/gitlab/conf/gitlab.rb

external_url 修改为 external_url 'http://192.168.68.128'

gitlab_rails['gitlab_shell_ssh_port'] 修改为 gitlab_rails['gitlab_shell_ssh_port'] = 2626

5、重新读取 gitlab 配置文件,可以选择 restart 或者 gitlab-ctl:

gitlab-ctl 方式:

[[email protected] ] docker ps -a
[[email protected] ] docker exec -it 7f0ad4d84ec0 bash
[email protected]:/# gitlab-ctl reconfigure

docker

成功如下图:

docker

restart 方式,成功如下图:

[[email protected] ] docker restart gitlab

docker

6、通过 nginx 反向代理 gitlab 的 8000 端口

[[email protected] ] vim /data/nginx/conf/conf.d/gitlab.com.conf

server {
  listen 80;
  server_name localhost;

  location / {
   proxy_pass http://127.0.0.1:8000/;
   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;
   access_log /data/logs/gitlab.com-access.log log_access;
   error_log  /data/logs/gitlab.com-error.log;
  }
}

7、访问 gitlab,http://192.168.68.128 ,如下图:
gitlab

能正常访问,则说明 gitlab 部署成功!

赞(0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址