Docker下安装gitlab

作者: haopangang | 来源:发表于2019-03-25 16:43 被阅读2次

    系统信息:基于Ubuntu16.04的docker容器
    主要内容:安装gitlab以及遇到的问题

    1、在线安装

    在线比较简单主要有以下几个步骤

    1. Install and configure the necessary dependencies

      sudo apt-get update

      sudo apt-get install -y curl openssh-server ca-certificates

    2. Add the GitLab package repository and install the package

      curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash

      apt-get install gitlab-ee

    3. Start gitlab

      gitlab-ctl reconfigure

      gitlab-ctl start

    这是官网给出的方法,地址如下:gitlab安装地址,如果不出任何意外,基本上就可以使用。

    2、离线安装

    gitlab依赖openssh。所以在安装之前要先安装openssh。需要的包如下:

    1. openssh-client_7.2p2-4_amd64.debopenssh-server_7.2p2-4_amd64.deb
    2. gitlib-ce-11.8.3

    下载好之后直接使用以下命令安装即可:

    sudo dpkg -i xxx.deb

    3、docker安装出现的问题

    docker安装以后,执行gitlab-ctl reconfigure 卡在ruby_block[supervise_redis_sleep] action run 无法向下进行,部分错误代码如下:

      * file[/opt/gitlab/embedded/service/gitlab-rails/db/schema.rb] action create (up to date)
      * remote_file[/var/opt/gitlab/gitlab-rails/VERSION] action create (up to date)
      * execute[chown -R git /opt/gitlab/embedded/service/gitlab-rails/public] action run
        - execute chown -R git /opt/gitlab/embedded/service/gitlab-rails/public
    
      * execute[clear the gitlab-rails cache] action nothing (skipped due to action :nothing)
    Recipe: gitlab::default
      * service[unicorn] action nothing (up to date)
      * service[sidekiq] action nothing (up to date)
    Recipe: runit::sysvinit
      * execute[echo 'CS:123456:respawn:/opt/gitlab/embedded/bin/runsvdir-start' >> /etc/inittab] action run (skipped due to not_if)
      * execute[init q] action nothing (skipped due to action :nothing)
    Recipe: gitlab::redis
      * user[gitlab-redis] action create (up to date)
      * directory[/var/log/gitlab/redis] action create (up to date)
      * directory[/var/opt/gitlab/redis] action create (up to date)
      * template[/var/opt/gitlab/redis/redis.conf] action create (up to date)
      * directory[/opt/gitlab/sv/redis] action create (up to date)
      * directory[/opt/gitlab/sv/redis/log] action create (up to date)
      * directory[/opt/gitlab/sv/redis/log/main] action create (up to date)
      * template[/opt/gitlab/sv/redis/run] action create (up to date)
      * template[/opt/gitlab/sv/redis/log/run] action create (up to date)
      * file[/opt/gitlab/sv/redis/down] action delete (up to date)
      * link[/opt/gitlab/init/redis] action create (up to date)
      * link[/opt/gitlab/service/redis] action create (up to date)
      * ruby_block[supervise_redis_sleep] action run
    
    

    官网给出的方法是

    systemctl restart gitlab-runsvdir.service

    然后再执行启动gitlab的命令。具体问题地址

    但是使用docker装gitlab时,自己遇到了问题,比如输入systemctl restart gitlab-runsvdir.service时,会出现下面问题:

    Failed to connect to bus: No such file or directory
    

    出现这问题时,一般是我们启动的时候加上下面的加粗的参数即可

    docker run -d -p 8000:8000 -p 8880:80 -p 8443:443 -v /root/.m2:/root/.m2 -v /u01/dockerFile:/myfile -t -i --privileged=true gitlab:v1 /sbin/init

    如果还没法启动成功,说明在/lib/systemd/system文件夹下么有gitlab-runsvdir.service,所以我们要把安装的gitlab-runsvdir.service赋值进来。执行

    find / -name gitlab-runsvdir.service

    找到路径,复制到/lib/systemd/system,例如我找到的地址如下:

    /opt/gitlab/embedded/cookbooks/package/files/default/gitlab-runsvdir.service
    

    之后再执行systemctl restart gitlab-runsvdir.service就可以启动了,剩下启动gitlab就只需要等待即可。

    相关文章

      网友评论

        本文标题:Docker下安装gitlab

        本文链接:https://www.haomeiwen.com/subject/xtjbvqtx.html