Docker部署应用-部署GitLab

1、前置准备

   1)CentOS 8.0 图形化安装
   2)CentOS 8.0 基本配置
   3)CentOS 8.0 创建LVM分区
   4)CentOS 8.1 安装Docker

2、拉取GitLab镜像

[root@Server ~]# docker image ls -a
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
ubuntu                  20.04               1d622ef86b13        2 weeks ago         73.9MB
nginx                   1.17.10             e791337790a6        3 weeks ago         127MB
httpd                   2.4.43              bdc169d27d36        3 weeks ago         166MB
continuumio/anaconda3   2020.02             bdb4a7e92a49        2 months ago        2.7GB
registry                2.7.1               708bc6af7e5e        3 months ago        25.8MB
centos                  8.1.1911            470671670cac        3 months ago        237MB
elleflorio/svn-server   latest              8cc13133f6ed        4 months ago        49.7MB
[root@Server ~]# docker pull gitlab/gitlab-ce:12.10.3-ce.0
12.10.3-ce.0: Pulling from gitlab/gitlab-ce
e92ed755c008: Pull complete
b9fd7cb1ff8f: Pull complete
ee690f2d57a1: Pull complete
53e3366ec435: Pull complete
694ece8a2b03: Pull complete
ec4c21b48d6f: Pull complete
c85f3c7b31ce: Pull complete
18e5c37a7635: Pull complete
e49266b737ef: Pull complete
64b54ac47dbe: Pull complete
Digest: sha256:9b851819c48af7de7bff343c8240c028831e5861153b6c85af6877674d74126b
Status: Downloaded newer image for gitlab/gitlab-ce:12.10.3-ce.0
docker.io/gitlab/gitlab-ce:12.10.3-ce.0
[root@Server ~]# docker image ls -a
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
gitlab/gitlab-ce        12.10.3-ce.0        f2e48729e35c        8 days ago          2GB
ubuntu                  20.04               1d622ef86b13        2 weeks ago         73.9MB
nginx                   1.17.10             e791337790a6        3 weeks ago         127MB
httpd                   2.4.43              bdc169d27d36        3 weeks ago         166MB
continuumio/anaconda3   2020.02             bdb4a7e92a49        2 months ago        2.7GB
registry                2.7.1               708bc6af7e5e        3 months ago        25.8MB
centos                  8.1.1911            470671670cac        3 months ago        237MB
elleflorio/svn-server   latest              8cc13133f6ed        4 months ago        49.7MB

3、运行正式容器

[root@Server ~]# docker container ls -a
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                                                   NAMES
1239e6c4f462        continuumio/anaconda3:2020.02   "/bin/bash"              2 weeks ago         Up 10 days          0.0.0.0:8003->8888/tcp                                  condasrv
8d9c6f28311e        registry:2.7.1                  "/entrypoint.sh /etc…"   2 weeks ago         Up 2 weeks          0.0.0.0:8005->5000/tcp                                  registry
2cbebbcb3a64        centos:8.1.1911                 "/bin/bash"              2 weeks ago         Up 2 weeks          0.0.0.0:8004->80/tcp                                    vscodeweb
b573bedbb67c        elleflorio/svn-server:latest    "/init"                  2 weeks ago         Up 2 weeks          443/tcp, 0.0.0.0:3690->3690/tcp, 0.0.0.0:8001->80/tcp   svnsrv
bf9d05430205        httpd:2.4.43                    "httpd-foreground"       3 weeks ago         Up 2 weeks          0.0.0.0:8002->80/tcp                                    apachesrv
7a5b653ef143        nginx:1.17.10                   "nginx -g 'daemon of…"   3 weeks ago         Up 2 weeks          0.0.0.0:8000->80/tcp                                    nginxsrv
[root@Server ~]# docker run --detach \
> --hostname gitlab \
> --publish 8006:443 --publish 8007:8007 --publish 8008:22 \
> --name gitlab \
> --privileged=true --restart always \
> --volume /data/gitlab/conf:/etc/gitlab \
> --volume /data/gitlab/logs:/var/log/gitlab \
> --volume /data/gitlab/data:/var/opt/gitlab \
> gitlab/gitlab-ce:12.10.3-ce.0
bbf971008534a367a5801a9d8ff3cfe34c0ab2d416e6ad381883be2f29eb17df
[root@Server ~]# docker container ls -a
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS                             PORTS                                                               NAMES
bbf971008534        gitlab/gitlab-ce:12.10.3-ce.0   "/assets/wrapper"        2 minutes ago       Up 27 seconds (health: starting)   0.0.0.0:8008->22/tcp, 0.0.0.0:8007->8007/tcp, 0.0.0.0:8006->443/tcp   gitlab
1239e6c4f462        continuumio/anaconda3:2020.02   "/bin/bash"              2 weeks ago         Up 10 days                         0.0.0.0:8003->8888/tcp                                              condasrv
8d9c6f28311e        registry:2.7.1                  "/entrypoint.sh /etc…"   2 weeks ago         Up 2 weeks                         0.0.0.0:8005->5000/tcp                                              registry
2cbebbcb3a64        centos:8.1.1911                 "/bin/bash"              2 weeks ago         Up 2 weeks                         0.0.0.0:8004->80/tcp                                                vscodeweb
b573bedbb67c        elleflorio/svn-server:latest    "/init"                  2 weeks ago         Up 2 weeks                         443/tcp, 0.0.0.0:3690->3690/tcp, 0.0.0.0:8001->80/tcp               svnsrv
bf9d05430205        httpd:2.4.43                    "httpd-foreground"       3 weeks ago         Up 2 weeks                         0.0.0.0:8002->80/tcp                                                apachesrv
7a5b653ef143        nginx:1.17.10                   "nginx -g 'daemon of…"   3 weeks ago         Up 2 weeks                         0.0.0.0:8000->80/tcp  

4、配置GitLab

[root@Server ~]# vi /data/gitlab/conf/gitlab.rb
# 配置http协议所使用的访问地址,不加端口号默认为80
external_url 'http://119.28.63.45:8007'

# 配置ssh协议所使用的访问地址和端口
gitlab_rails['gitlab_ssh_host'] = '119.28.63.45'
gitlab_rails['gitlab_shell_ssh_port'] = 8008 # 此端口是run时22端口映射的8008端口
[root@Server ~]# docker container exec -it gitlab /bin/bash
root@gitlab:/#
root@gitlab:~# vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
# 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`.

production: &base
  #
  # 1. GitLab app settings
  # ==========================

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: 119.28.63.45
    port: 8007
    https: false
root@gitlab:~# exit
exit
[root@Server ~]#
[root@Server ~]# docker exec gitlab gitlab-ctl reconfigure
Starting Chef Client, version 14.14.29
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - package (0.1.0)
  - postgresql (0.1.0)
  - redis (0.1.0)
  - monitoring (0.1.0)
  - registry (0.1.0)
  - mattermost (0.1.0)
  - consul (0.1.0)
  - gitaly (0.1.0)
  - praefect (0.1.0)
  - letsencrypt (0.1.0)
  - nginx (0.1.0)
  - runit (4.3.0)
  - acme (4.1.1)
  - crond (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
(此处省略……)
Recipe: monitoring::grafana
  * runit_service[grafana] action restart (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 11/705 resources updated in 29 seconds
gitlab Reconfigured!
[root@Server ~]# docker container restart gitlab
gitlab
[root@Server ~]# docker container ls -a | grep gitlab
bbf971008534        gitlab/gitlab-ce:12.10.3-ce.0   "/assets/wrapper"        2 hours ago         Up About a minute (healthy)   0.0.0.0:8008->22/tcp, 0.0.0.0:8007->80/tcp, 0.0.0.0:8006->443/tcp   gitlab

5、访问并初始化GitLab

第一次访问设置密码
设置密码后登录
登录成功进入主页

6、重置root密码

[root@Server ~]# docker exec -it gitlab bash
root@gitlab:/#  gitlab-rails console -e production

--------------------------------------------------------------------------------
 Ruby:         ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]
 GitLab:       16.5.1 (d59d7a49a1f) FOSS
 GitLab Shell: 14.29.0
 PostgreSQL:   13.11
------------------------------------------------------------[ booted in 72.57s ]
Loading production environment (Rails 7.0.8)
irb(main):001:0>
irb(main):002:0> user = User.find_by(username: 'root')
=> #<User id:1 @root>
irb(main):003:0> user.password = '1qaz@WSX'
=> "1qaz@WSX"
irb(main):004:0> user.password_confirmation = '1qaz@WSX'
=> "1qaz@WSX"
irb(main):012:0> user.save!
=> true
irb(main):013:0> exit
root@gitlab:/# exit
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 221,635评论 6 515
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 94,543评论 3 399
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 168,083评论 0 360
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,640评论 1 296
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,640评论 6 397
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 52,262评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,833评论 3 421
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,736评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 46,280评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,369评论 3 340
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,503评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 36,185评论 5 350
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,870评论 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,340评论 0 24
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,460评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,909评论 3 376
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,512评论 2 359