移动dockerized GitLab数据卷的位置

时间:2016-09-14 00:54:26

标签: docker gitlab

我正在使用找到here的8.11.0-ce.1图像运行GitLab。我将docker-compose卷配置为:

  volumes:
    - './data/config:/etc/gitlab'
    - './data/logs:/var/log/gitlab'
    - './data/data:/var/opt/gitlab'

但是这个磁盘的大小有限,我希望将这些卷移动到更大的/ data / gitlab /目录。

为了做到这一点,我尝试了以下步骤: 1.带走码头工人的容器 2.复制数据量(cp -r / app / gitlab / data / / data / gitlab) 3.将docker-compose.yml修改为

  volumes:
    - '/data/gitlab/config:/etc/gitlab'
    - '/data/gitlab/logs:/var/log/gitlab'
    - '/data/gitlab/data:/var/opt/gitlab'

然而,在重新启动容器时,我得到一个连续重复的错误(见下文)。我假设还有一个必须遵循的额外步骤?或者我不正确地解决这个问题?

gitlab_1  | Preparing services...
gitlab_1  | Starting services...
gitlab_1  | Configuring GitLab package...
gitlab_1  | Configuring GitLab...
gitlab_1  | /opt/gitlab/embedded/bin/runsvdir-start: line 24: ulimit: pending signals: cannot modify limit: Operation not permitted
gitlab_1  | /opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted
gitlab_1  | /opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
gitlab_1  |
gitlab_1  | ================================================================================
gitlab_1  | Error executing action `run` on resource 'execute[/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions]'
gitlab_1  | ================================================================================
gitlab_1  |
gitlab_1  | Mixlib::ShellOut::ShellCommandFailed
gitlab_1  | ------------------------------------
gitlab_1  | Expected process to exit with [0], but received '1'
gitlab_1  | ---- Begin output of /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions ----
gitlab_1  | STDOUT:
gitlab_1  | STDERR: /opt/gitlab/embedded/lib/ruby/2.3.0/logger.rb:703:in `initialize': Permission denied @ rb_sysopen - /var/log/gitlab/gitlab-shell/gitlab-shell.log (Errno::EACCES)
gitlab_1  |     from /opt/gitlab/embedded/lib/ruby/2.3.0/logger.rb:703:in `open'
gitlab_1  |     from /opt/gitlab/embedded/lib/ruby/2.3.0/logger.rb:703:in `open_logfile'
gitlab_1  |     from /opt/gitlab/embedded/lib/ruby/2.3.0/logger.rb:695:in `set_dev'
gitlab_1  |     from /opt/gitlab/embedded/lib/ruby/2.3.0/logger.rb:635:in `initialize'
gitlab_1  |     from /opt/gitlab/embedded/lib/ruby/2.3.0/logger.rb:353:in `new'
gitlab_1  |     from /opt/gitlab/embedded/lib/ruby/2.3.0/logger.rb:353:in `initialize'
gitlab_1  |     from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_logger.rb:15:in `new'
gitlab_1  |     from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_logger.rb:15:in `<top (required)>'
gitlab_1  |     from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_keys.rb:4:in `require_relative'
gitlab_1  |     from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_keys.rb:4:in `<top (required)>'
gitlab_1  |     from /opt/gitlab/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
gitlab_1  |     from /opt/gitlab/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
gitlab_1  |     from /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys:24:in `<main>'
gitlab_1  | ---- End output of /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions ----
gitlab_1  | Ran /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions returned 1
gitlab_1  |
gitlab_1  | Resource Declaration:
gitlab_1  | ---------------------
gitlab_1  | # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/gitlab-shell.rb
gitlab_1  |
gitlab_1  | 124: execute "#{gitlab_shell_keys_check} check-permissions" do
gitlab_1  | 125:   user git_user
gitlab_1  | 126:   group git_group
gitlab_1  | 127: end
gitlab_1  | 128:
gitlab_1  |
gitlab_1  | Compiled Resource:
gitlab_1  | ------------------
gitlab_1  | # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/gitlab-shell.rb:124:in `from_file'
gitlab_1  |
gitlab_1  | execute("/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions") do
gitlab_1  |   action [:run]
gitlab_1  |   retries 0
gitlab_1  |   retry_delay 2
gitlab_1  |   default_guard_interpreter :execute
gitlab_1  |   command "/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions"
gitlab_1  |   backup 5
gitlab_1  |   group "git"
gitlab_1  |   returns 0
gitlab_1  |   user "git"
gitlab_1  |   declared_type :execute
gitlab_1  |   cookbook_name "gitlab"
gitlab_1  |   recipe_name "gitlab-shell"
gitlab_1  | end
gitlab_1  |
gitlab_1  | Platform:
gitlab_1  | ---------
gitlab_1  | x86_64-linux
gitlab_1  |

2 个答案:

答案 0 :(得分:3)

TL; DR - 尝试使用cp -a代替cp -r

<强>详情:

我快速使用https://docs.gitlab.com/omnibus/docker/#install-gitlab-using-docker-compose的撰写文件。我确实看到了和你一样的错误。这显然是某种许可问题。我注意到容器启动时有一个方便的提示,说:

# docker-compose up
Recreating gitlab2_web_1
Attaching to gitlab2_web_1
web_1  | Thank you for using GitLab Docker Image!
web_1  | Current version: gitlab-ce=8.11.5-ce.0
web_1  |
web_1  | Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
web_1  | And restart this container to reload settings.
web_1  | To do it use docker exec:
web_1  |
web_1  |   docker exec -it gitlab vim /etc/gitlab/gitlab.rb
web_1  |   docker restart gitlab
web_1  |
web_1  | For a comprehensive list of configuration options please see the Omnibus GitLab readme
web_1  | https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
web_1  |
web_1  | If this container fails to start due to permission problems try to fix it by executing:
web_1  |
web_1  |   docker exec -it gitlab update-permissions
web_1  |   docker restart gitlab
web_1  |
web_1  | Preparing services...
web_1  | Starting services...

我尝试了一些有限的成功......按照指示运行有点棘手,因为容器正在不断重启。既然你是通过compose运行的,你可以添加:

entrypoint: update-permissions

即。像这样的东西:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.example.com'
  entrypoint: update-permissions
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://gitlab.example.com'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '80:80'
    - '443:443'
    - '22:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'

到相关的服务配置。它将重新创建容器,但这没关系。但是,对我来说,在我做完之后,我似乎仍然遇到了一些redis问题。

由于这只是磁盘上的文件,我想我会在复制时保留所有权等,这似乎工作正常。在你的情况下,我想是的:

cp -a /app/gitlab/data/ /data/gitlab

答案 1 :(得分:2)

这是我移动一个有争议的GitLab位置的步骤:

  1. 运行新的GitLab实例,例如:

    java.lang.UnsupportedOperationException: AudioEffect: invalid parameter    
    operation
    at android.media.audiofx.AudioEffect.checkStatus(AudioEffect.java:1271)
    at android.media.audiofx.BassBoost.setStrength(BassBoost.java:127)
    
  2. 片刻之后停止容器中的所有服务,以避免冲突:

    docker run --detach \
        --hostname gitlab.example.com \
        --publish 443:443 --publish 80:80 --publish 22:22 \
        --name gitlab \
        --restart always \
        --volume /srv/gitlab/config:/etc/gitlab \
        --volume /srv/gitlab/logs:/var/log/gitlab \
        --volume /srv/gitlab/data:/var/opt/gitlab \
        gitlab/gitlab-ce:latest
    
  3. 将重要数据和配置文件夹复制到新GitLab 来自旧GitLab的容器。假设你的新GitLab容器 它被称为 gitlab ,并且您的旧GitLab卷位置是 docker exec -it gitlab /bin/bash -c 'gitlab-ctl stop unicorn && gitlab-ctl stop sidekiq && gitlab-ctl stop' (参见步骤1中我的卷位置的参考):

    /srv/

    (替换您的位置服务器docker exec -it -u git gitlab /bin/bash -c 'rsync -avz user@SERVER_LOCATION:/srv/gitlab/config/* /etc/gitlab/' docker exec -it -u git gitlab /bin/bash -c 'rsync -avz user@SERVER_LOCATION:/srv/gitlab/logs/* /var/log/gitlab/' docker exec -it -u git gitlab /bin/bash -c 'rsync -avz user@SERVER_LOCATION:/srv/gitlab/data/* /var/opt/gitlab/ 。如果您在同一台计算机上有文件,请使用SERVER_LOCATION命令。)

  4. 重新启动容器:

    docker cp
  5. 几秒钟后(20 aprox。依赖您的机器)更新 权限文件:

    docker restart gitlab
    

    检查正确的工作:

    docker exec -it gitlab /bin/bash -c "chown -R git /var/opt/gitlab/gitlab-rails/uploads && find /var/opt/gitlab/gitlab-rails/uploads -type f -exec chmod 0644 {} \; && find /var/opt/gitlab/gitlab-rails/uploads -type d -not -path /var/opt/gitlab/gitlab-rails/uploads -exec chmod 0700 {} \;"
    docker exec -it gitlab /bin/bash -c 'update-permissions'
    

    (如果在此步骤中它返回任何错误,请阅读消息并应用推荐。)

  6. 生成初始迁移的备份(如果需要):

    docker exec -it gitlab /bin/bash -c 'gitlab-rake gitlab:check SANITIZE=true'