使用Docker-Compose安装GitLab服务器

1. 请将下面代码保持为docker-compose.yml,然后在bash命令行中执行docker-compose up即可

version: '2'

services:
  redis:
    restart: always
    image: sameersbn/redis:4.0.9-1
    command:
    - --loglevel warning
    volumes:
    - ~/docker/gitlab/redis:/var/lib/redis:Z

  postgresql:
    restart: always
    image: sameersbn/postgresql:10
    volumes:
    - ~/docker/gitlab/postgresql:/var/lib/postgresql:Z
    environment:
    - DB_USER=gitlab
    - DB_PASS=password
    - DB_NAME=gitlabhq_production
    - DB_EXTENSION=pg_trgm

  gitlab:
    restart: always
    image: sameersbn/gitlab
    depends_on:
    - redis
    - postgresql
    ports:
    - "10080:80"
    - "10022:22"
    volumes:
    - ~/docker/gitlab/gitlab:/home/git/data:Z
    environment:
    - DEBUG=false

    - DB_ADAPTER=postgresql
    - DB_HOST=postgresql
    - DB_PORT=5432
    - DB_USER=gitlab
    - DB_PASS=password
    - DB_NAME=gitlabhq_production

    - REDIS_HOST=redis
    - REDIS_PORT=6379

    - TZ=Asia/Kolkata
    - GITLAB_TIMEZONE=Kolkata

    - GITLAB_HTTPS=false
    - SSL_SELF_SIGNED=false

    - GITLAB_HOST=localhost
    - GITLAB_PORT=10080
    - GITLAB_SSH_PORT=10022
    - GITLAB_RELATIVE_URL_ROOT=
    - GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alphanumeric-string
    - GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alphanumeric-string
    - GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alphanumeric-string

    - GITLAB_ROOT_PASSWORD=
    - GITLAB_ROOT_EMAIL=

    - GITLAB_NOTIFY_ON_BROKEN_BUILDS=true
    - GITLAB_NOTIFY_PUSHER=false

    - GITLAB_EMAIL=notifications@example.com
    - GITLAB_EMAIL_REPLY_TO=noreply@example.com
    - GITLAB_INCOMING_EMAIL_ADDRESS=reply@example.com

    - GITLAB_BACKUP_SCHEDULE=daily
    - GITLAB_BACKUP_TIME=01:00

    - SMTP_ENABLED=false
    - SMTP_DOMAIN=www.example.com
    - SMTP_HOST=smtp.gmail.com
    - SMTP_PORT=587
    - SMTP_USER=mailer@example.com
    - SMTP_PASS=password
    - SMTP_STARTTLS=true
    - SMTP_AUTHENTICATION=login

    - IMAP_ENABLED=false
    - IMAP_HOST=imap.gmail.com
    - IMAP_PORT=993
    - IMAP_USER=mailer@example.com
    - IMAP_PASS=password
    - IMAP_SSL=true
    - IMAP_STARTTLS=false

    - OAUTH_ENABLED=false
    - OAUTH_AUTO_SIGN_IN_WITH_PROVIDER=
    - OAUTH_ALLOW_SSO=
    - OAUTH_BLOCK_AUTO_CREATED_USERS=true
    - OAUTH_AUTO_LINK_LDAP_USER=false
    - OAUTH_AUTO_LINK_SAML_USER=false
    - OAUTH_EXTERNAL_PROVIDERS=

    - OAUTH_CAS3_LABEL=cas3
    - OAUTH_CAS3_SERVER=
    - OAUTH_CAS3_DISABLE_SSL_VERIFICATION=false
    - OAUTH_CAS3_LOGIN_URL=/cas/login
    - OAUTH_CAS3_VALIDATE_URL=/cas/p3/serviceValidate
    - OAUTH_CAS3_LOGOUT_URL=/cas/logout

    - OAUTH_GOOGLE_API_KEY=
    - OAUTH_GOOGLE_APP_SECRET=
    - OAUTH_GOOGLE_RESTRICT_DOMAIN=

    - OAUTH_FACEBOOK_API_KEY=
    - OAUTH_FACEBOOK_APP_SECRET=

    - OAUTH_TWITTER_API_KEY=
    - OAUTH_TWITTER_APP_SECRET=

    - OAUTH_GITHUB_API_KEY=
    - OAUTH_GITHUB_APP_SECRET=
    - OAUTH_GITHUB_URL=
    - OAUTH_GITHUB_VERIFY_SSL=

    - OAUTH_GITLAB_API_KEY=
    - OAUTH_GITLAB_APP_SECRET=

    - OAUTH_BITBUCKET_API_KEY=
    - OAUTH_BITBUCKET_APP_SECRET=

    - OAUTH_SAML_ASSERTION_CONSUMER_SERVICE_URL=
    - OAUTH_SAML_IDP_CERT_FINGERPRINT=
    - OAUTH_SAML_IDP_SSO_TARGET_URL=
    - OAUTH_SAML_ISSUER=
    - OAUTH_SAML_LABEL="Our SAML Provider"
    - OAUTH_SAML_NAME_IDENTIFIER_FORMAT=urn:oasis:names:tc:SAML:2.0:nameid-format:transient
    - OAUTH_SAML_GROUPS_ATTRIBUTE=
    - OAUTH_SAML_EXTERNAL_GROUPS=
    - OAUTH_SAML_ATTRIBUTE_STATEMENTS_EMAIL=
    - OAUTH_SAML_ATTRIBUTE_STATEMENTS_NAME=
    - OAUTH_SAML_ATTRIBUTE_STATEMENTS_FIRST_NAME=
    - OAUTH_SAML_ATTRIBUTE_STATEMENTS_LAST_NAME=

    - OAUTH_CROWD_SERVER_URL=
    - OAUTH_CROWD_APP_NAME=
    - OAUTH_CROWD_APP_PASSWORD=

    - OAUTH_AUTH0_CLIENT_ID=
    - OAUTH_AUTH0_CLIENT_SECRET=
    - OAUTH_AUTH0_DOMAIN=

    - OAUTH_AZURE_API_KEY=
    - OAUTH_AZURE_API_SECRET=
    - OAUTH_AZURE_TENANT_ID=

2. 执行docker-compose.yml文件

# 执行代码前先保证以及在本地创建好相应目录,如果没有执行下面代码创建
$ cd ~
$ mkdir docker
$ cd docker
$ mkdir gitlab
$ cd gitlab
$ mkdir postgresql
$ mkdir redis
$ mkdir gitlab

# 这样才能保证本地挂载的目录存在
# cd ~/docker/gitlab/postgresql #检测目录是否创建成功
# cd ~/docker/gitlab/gitlab     #检测目录是否创建成功
# cd ~/docker/gitlab/redis      #检测目录是否创建成功

# 默认方式执行,默认打印启动日志,启动可能会有几分钟
$ docker-compose up 

# 后台运行,不打印启动日志
$ docker-compose up -d

# 默认会创建三个容器,一个启动postgres服务器,一个启动redis缓存服务器,一个启动gitlab服务器
# 启动后默认会进行初始配置,需要一段时间,请耐心等待
# 启动完成后,请在浏览器打开 http://127.0.0.1:10080即可
# 如果docker-compose.yml中的默认端口已经被改,访问http://127.0.0.1[:your port]即可

# 如果以前没有下载相应的镜像,执行完命令后会自动下载,当前版本的镜像大约2G左右,需要一段时间
# 镜像下载完毕后为自动执行创建容器,并启动服务器的操作


3. 启动日志信息

MacdeMacBook-Pro:gitlab mac$ docker-compose up
Creating gitlab_postgresql_1_2a4924d682fe ... done
Creating gitlab_redis_1_44a326dd88bf      ... done
Creating gitlab_gitlab_1_70e7a2063e08     ... done
Attaching to gitlab_redis_1_ad872d40d576, gitlab_postgresql_1_dafaec3696c9, gitlab_gitlab_1_43d512937f9c
redis_1_ad872d40d576 | Starting redis-server...
postgresql_1_dafaec3696c9 | Initializing datadir...
gitlab_1_43d512937f9c | Loading /etc/docker-gitlab/runtime/env-defaults
redis_1_ad872d40d576 | 1:C 25 Nov 08:59:17.678 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1_ad872d40d576 | 1:C 25 Nov 08:59:17.678 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1_ad872d40d576 | 1:C 25 Nov 08:59:17.678 # Configuration loaded
redis_1_ad872d40d576 | 1:M 25 Nov 08:59:17.686 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1_ad872d40d576 | 1:M 25 Nov 08:59:17.686 # Server initialized
redis_1_ad872d40d576 | 1:M 25 Nov 08:59:17.687 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
gitlab_1_43d512937f9c | Initializing logdir...
gitlab_1_43d512937f9c | Initializing datadir...
gitlab_1_43d512937f9c | Installing configuration templates...
gitlab_1_43d512937f9c | Configuring gitlab...
postgresql_1_dafaec3696c9 | Initializing certdir...
postgresql_1_dafaec3696c9 | Initializing logdir...
postgresql_1_dafaec3696c9 | Initializing rundir...
postgresql_1_dafaec3696c9 | Setting resolv.conf ACLs...
postgresql_1_dafaec3696c9 | Creating database user: gitlab
postgresql_1_dafaec3696c9 | Creating database: gitlabhq_production...
postgresql_1_dafaec3696c9 | ‣ Loading pg_trgm extension...
postgresql_1_dafaec3696c9 | ‣ Granting access to gitlab user...
postgresql_1_dafaec3696c9 | Starting PostgreSQL 10...
postgresql_1_dafaec3696c9 | 2018-11-25 08:59:37.639 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgresql_1_dafaec3696c9 | 2018-11-25 08:59:37.640 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgresql_1_dafaec3696c9 | 2018-11-25 08:59:37.649 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresql_1_dafaec3696c9 | 2018-11-25 08:59:37.859 UTC [2381] LOG:  database system was shut down at 2018-11-25 08:59:37 UTC
postgresql_1_dafaec3696c9 | 2018-11-25 08:59:37.914 UTC [1] LOG:  database system is ready to accept connections
gitlab_1_43d512937f9c | Configuring gitlab::database..................
gitlab_1_43d512937f9c | Configuring gitlab::redis
gitlab_1_43d512937f9c | Configuring gitlab::secrets...
gitlab_1_43d512937f9c | Configuring gitlab::sidekiq...
gitlab_1_43d512937f9c | Configuring gitlab::gitaly...
gitlab_1_43d512937f9c | Configuring gitlab::monitoring...
gitlab_1_43d512937f9c | Configuring gitlab::gitlab-workhorse...
gitlab_1_43d512937f9c | Configuring gitlab::unicorn...
gitlab_1_43d512937f9c | Configuring gitlab::timezone...
gitlab_1_43d512937f9c | Configuring gitlab::rack_attack...
gitlab_1_43d512937f9c | Configuring gitlab::ci...
gitlab_1_43d512937f9c | Configuring gitlab::artifacts...
gitlab_1_43d512937f9c | Configuring gitlab::lfs...
gitlab_1_43d512937f9c | Configuring gitlab::uploads...
gitlab_1_43d512937f9c | Configuring gitlab::mattermost...
gitlab_1_43d512937f9c | Configuring gitlab::project_features...
gitlab_1_43d512937f9c | Configuring gitlab::oauth...
gitlab_1_43d512937f9c | Configuring gitlab::ldap...
gitlab_1_43d512937f9c | Configuring gitlab::cron_jobs...
gitlab_1_43d512937f9c | Configuring gitlab::backups...
gitlab_1_43d512937f9c | Configuring gitlab::backups::schedule...
gitlab_1_43d512937f9c | Configuring gitlab::registry...
gitlab_1_43d512937f9c | Configuring gitlab::pages...
gitlab_1_43d512937f9c | Configuring gitlab-shell...
gitlab_1_43d512937f9c | Configuring nginx...
gitlab_1_43d512937f9c | Configuring nginx::gitlab...
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,201 CRIT Supervisor running as root (no user in config file)
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,201 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,201 WARN Included extra file "/etc/supervisor/conf.d/gitaly.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,201 WARN Included extra file "/etc/supervisor/conf.d/gitlab-workhorse.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,201 WARN Included extra file "/etc/supervisor/conf.d/mail_room.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,202 WARN Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,202 WARN Included extra file "/etc/supervisor/conf.d/sidekiq.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,203 WARN Included extra file "/etc/supervisor/conf.d/sshd.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,203 WARN Included extra file "/etc/supervisor/conf.d/unicorn.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,227 INFO RPC interface 'supervisor' initialized
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,229 CRIT Server 'unix_http_server' running without any HTTP authentication checking
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,230 INFO supervisord started with pid 622
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,375 INFO spawned: 'gitaly' with pid 636
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,380 INFO spawned: 'sidekiq' with pid 637
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,384 INFO spawned: 'unicorn' with pid 638
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,389 INFO spawned: 'gitlab-workhorse' with pid 642
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,401 INFO spawned: 'cron' with pid 644
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,409 INFO spawned: 'nginx' with pid 646
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,421 INFO spawned: 'sshd' with pid 649
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,424 WARN received SIGTERM indicating exit request
gitlab_1_43d512937f9c | 2018-11-25 14:29:40,427 INFO waiting for sshd, gitlab-workhorse, sidekiq, cron, nginx, gitaly, unicorn to die
gitlab_1_43d512937f9c | 2018-11-25 14:29:41,658 INFO success: gitaly entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:29:41,658 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:29:41,659 INFO success: unicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:29:41,659 INFO success: gitlab-workhorse entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:29:41,660 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:29:41,660 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:29:43,948 INFO waiting for sshd, gitlab-workhorse, sidekiq, cron, nginx, gitaly, unicorn to die
gitlab_1_43d512937f9c | 2018-11-25 14:29:46,953 INFO waiting for sshd, gitlab-workhorse, sidekiq, cron, nginx, gitaly, unicorn to die
gitlab_1_43d512937f9c | 2018-11-25 14:29:49,958 INFO waiting for sshd, gitlab-workhorse, sidekiq, cron, nginx, gitaly, unicorn to die
gitlab_1_43d512937f9c | 2018-11-25 14:29:50,959 WARN killing 'sshd' (649) with SIGKILL
gitlab_1_43d512937f9c | 2018-11-25 14:29:50,961 INFO stopped: sshd (terminated by SIGKILL)
gitlab_1_43d512937f9c | 2018-11-25 14:29:50,969 INFO stopped: nginx (exit status 0)
gitlab_1_43d512937f9c | 2018-11-25 14:29:50,975 INFO stopped: cron (terminated by SIGTERM)
gitlab_1_43d512937f9c | 2018-11-25 14:29:50,979 INFO stopped: gitlab-workhorse (terminated by SIGTERM)
gitlab_1_43d512937f9c | 2018-11-25 14:29:52,984 INFO waiting for sidekiq, gitaly, unicorn to die
gitlab_1_43d512937f9c | 2018-11-25 14:29:56,969 INFO waiting for sidekiq, gitaly, unicorn to die
gitlab_1_43d512937f9c | 2018-11-25 14:29:59,975 INFO waiting for sidekiq, gitaly, unicorn to die
gitlab_1_43d512937f9c | 2018-11-25 14:30:02,981 WARN killing 'unicorn' (638) with SIGKILL
gitlab_1_43d512937f9c | 2018-11-25 14:30:02,982 INFO waiting for sidekiq, gitaly, unicorn to die
postgresql_1_dafaec3696c9 | 2018-11-25 09:00:03.045 UTC [2390] LOG:  could not receive data from client: Connection reset by peer
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,047 INFO stopped: unicorn (terminated by SIGKILL)
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,180 INFO stopped: sidekiq (terminated by SIGTERM)
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,211 INFO stopped: gitaly (exit status 1)
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,386 CRIT Supervisor running as root (no user in config file)
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,386 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,386 WARN Included extra file "/etc/supervisor/conf.d/gitaly.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,386 WARN Included extra file "/etc/supervisor/conf.d/gitlab-workhorse.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,386 WARN Included extra file "/etc/supervisor/conf.d/mail_room.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,386 WARN Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,387 WARN Included extra file "/etc/supervisor/conf.d/sidekiq.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,387 WARN Included extra file "/etc/supervisor/conf.d/sshd.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,387 WARN Included extra file "/etc/supervisor/conf.d/unicorn.conf" during parsing
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,397 INFO RPC interface 'supervisor' initialized
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,397 CRIT Server 'unix_http_server' running without any HTTP authentication checking
gitlab_1_43d512937f9c | 2018-11-25 14:30:03,398 INFO supervisord started with pid 1
gitlab_1_43d512937f9c | 2018-11-25 14:30:04,411 INFO spawned: 'gitaly' with pid 766
gitlab_1_43d512937f9c | 2018-11-25 14:30:04,415 INFO spawned: 'sidekiq' with pid 767
gitlab_1_43d512937f9c | 2018-11-25 14:30:04,461 INFO spawned: 'unicorn' with pid 774
gitlab_1_43d512937f9c | 2018-11-25 14:30:04,467 INFO spawned: 'gitlab-workhorse' with pid 775
gitlab_1_43d512937f9c | 2018-11-25 14:30:04,477 INFO spawned: 'cron' with pid 777
gitlab_1_43d512937f9c | 2018-11-25 14:30:04,481 INFO spawned: 'nginx' with pid 778
gitlab_1_43d512937f9c | 2018-11-25 14:30:04,484 INFO spawned: 'sshd' with pid 779
gitlab_1_43d512937f9c | 2018-11-25 14:30:05,719 INFO success: gitaly entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:30:05,719 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:30:05,719 INFO success: unicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:30:05,720 INFO success: gitlab-workhorse entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:30:05,723 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:30:05,723 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1_43d512937f9c | 2018-11-25 14:30:05,725 INFO success: sshd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

4. 访问gitlab服务器

#默认管理员账号为 root 

#初次访问http://127.0.0.1[:your port]时,进入默认账户root修改密码页面,此时更新你的密码即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值