移动dockerized GitLab数据卷的位置

我使用这里find的8.11.0-ce.1映像运行GitLab。 我把docker-compose卷configuration成这样:

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

但是,这个磁盘的大小有限,我想把这些卷移到更大的/ data / gitlab /目录下。

为了做到这一点,我尝试了以下步骤:1.docker容器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 | 

TL; DR – 尝试使用cp -a而不是cp -r

详情:

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

 # 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... 

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

 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' 

到相关的服务configuration。 它会重新创build容器,但没关系。 但是,对于我来说,在完成之后,我似乎仍然遇到了redis的一些问题。

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

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

这些是我移动位置GitLab的步骤:

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

     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 
  2. 在一会儿之后停止在您的容器requiered服务,以避免冲突:

     docker exec -it gitlab /bin/bash -c 'gitlab-ctl stop unicorn && gitlab-ctl stop sidekiq && gitlab-ctl stop' 
  3. 将重要的数据和configuration文件夹从旧的GitLab复制到新的GitLab容器中。 假设你的新的GitLab容器被称为gitlab ,并且旧的GitLab卷位置是/srv/ (请参阅步骤1中我的卷位置的引用):

     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_LOCATIONreplace为您的位置服务器,如果您的文件位于同一台计算机上,请使用docker cp命令。)

  4. 重新启动你的容器:

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

     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' 

    为了检查正确的工作:

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

    (如果在这一步它返回任何错误,阅读messange并应用推荐。)

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

     docker exec -it gitlab /bin/bash -c 'gitlab-rake gitlab:backup:create'