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

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

你可能感兴趣的:(Docker部署应用-部署GitLab)