【发布时间】:2017-07-17 01:53:22
【问题描述】:
TLDR;
有谁知道如何解决“断言“/var/opt/gitlab/git-data”的所有权是 git 失败”错误?
背景:
我想在 WindowsServer2012R2 上设置Gitlab Docker,运行 Docker 工具箱,版本 17.04.0-ce,构建 4845c56。
问题/疑问
我无法让共享文件夹在服务器的 D 盘上正常工作。我读到我需要将文件夹添加到 VirtualBox VM,这是通过 VB GUI 中的设置/共享文件夹菜单完成的。我为路径“D:\data\gitlab”设置了一个名称“gitlab”,然后检查了自动挂载,永久化,并将其设置为完全访问。
我启动了 docker 机器并运行了“docker-machine ssh $machine-name”。我注意到没有 /media 目录,所以我在主目录(/home/docker/gitlab)中添加了一个文件夹,然后使用我在几个论坛中找到的以下命令安装了共享文件夹:
sudo mount -t vboxsf gitlab /home/docker/gitlab
此时我可以将文件添加到 Windows 主机目录或 Docker 虚拟机,它似乎工作正常并且测试文件显示出来。
现在,当我启动 Gitlab Docker 映像时,我使用从他们的文档中修改的以下命令:
docker run --detach --hostname gitlab.example.com --publish 80:80 --name gitlab --volume /home/docker/gitlab:/etc/gitlab:Z --volume /home/docker/gitlab/logs:/var/log/gitlab:Z --volume /home/docker/gitlab/data:/var/opt/gitlab:Z gitlab/gitlab-ce
现在我知道它似乎正在写入共享驱动器,因为所有这些文件都已生成,但几秒钟后它崩溃并且我收到以下错误日志。
错误日志:
Thank you for using GitLab Docker Image!
Current version: gitlab-ce=9.3.6-ce.0
Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:
docker exec -it gitlab vim /etc/gitlab/gitlab.rb
docker restart gitlab
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
If this container fails to start due to permission problems try to fix it by executing:
docker exec -it gitlab update-permissions
docker restart gitlab
Installing gitlab.rb config...
Generating ssh_host_rsa_key...
Generating public/private rsa key pair.
Your identification has been saved in /etc/gitlab/ssh_host_rsa_key.
Your public key has been saved in /etc/gitlab/ssh_host_rsa_key.pub.
The key fingerprint is:
SHA256:GyFlf9tl7ZuEbuE+dwZUYiyahdsRzpC1T7kwyUvoD+o root@gitlab.example.com
The key's randomart image is:
+---[RSA 2048]----+
| o .+oo |
| o .o*+o+.o|
| . . o*@+oo+|
| . o+o.Oo= |
| S o o++..|
| + oo + o|
| o .+ + |
| . o. .o|
| E .o..|
+----[SHA256]-----+
Generating ssh_host_ecdsa_key...
Generating public/private ecdsa key pair.
Your identification has been saved in /etc/gitlab/ssh_host_ecdsa_key.
Your public key has been saved in /etc/gitlab/ssh_host_ecdsa_key.pub.
The key fingerprint is:
SHA256:Kb99jG8EtMuTSdIuqBT3GLeD1D0wwTEcQhKgVJUlBjs root@gitlab.example.com
The key's randomart image is:
+---[ECDSA 256]---+
| .o+=*=+=+ |
|.. oo..=.. |
|. E . * . |
| o + +.B |
| +.BS* * |
| . +o= B . |
| . . .o = |
| . o. + |
| . .+. |
+----[SHA256]-----+
Generating ssh_host_ed25519_key...
Generating public/private ed25519 key pair.
Your identification has been saved in /etc/gitlab/ssh_host_ed25519_key.
Your public key has been saved in /etc/gitlab/ssh_host_ed25519_key.pub.
The key fingerprint is:
SHA256:lVxpu0UoyNPWVY6D9c+m/bUTyvKP6vuR4cTOYwQ0j+U root@gitlab.example.com
The key's randomart image is:
+--[ED25519 256]--+
| . o +.=o..|
| +.=o@o.+ |
| o+=.Eo o|
| . + .o.|
| S B +|
| B o= |
| .Oo +|
| ..o+.+|
| .+*+.oo|
+----[SHA256]-----+
Preparing services...
Starting services...
Configuring GitLab package...
/opt/gitlab/embedded/bin/runsvdir-start: line 24: ulimit: pending signals: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 34: ulimit: max user processes: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
Configuring GitLab...
================================================================================
Error executing action `run` on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Failed asserting that ownership of "/var/opt/gitlab/git-data" was git
---- Begin output of set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] ----
STDOUT:
STDERR: + readlink -f /var/opt/gitlab/git-data
+ stat --printf=%U /var/opt/gitlab/git-data
+ [ UNKNOWN = git ]
---- End output of set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] ----
Ran set -x && [ "$(stat --printf='%U' $(readlink -f /var/opt/gitlab/git-data))" = 'git' ] returned 1
Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:124:in `validate_command'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:112:in `block in validate'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:111:in `each_index'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:111:in `validate'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/storage_directory_helper.rb:87:in `validate!'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:35:in `block (3 levels) in from_file'
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb
26: ruby_block "directory resource: #{params[:path]}" do
27: block do
28: # Ensure the directory exists
29: storage_helper.ensure_directory_exists(params[:path])
30:
31: # Ensure the permissions are set
32: storage_helper.ensure_permissions_set(params[:path])
33:
34: # Error out if we have not achieved the target permissions
35: storage_helper.validate!(params[:path])
36: end
37: not_if { storage_helper.validate(params[:path]) }
38: end
39: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:26:in `block in from_file'
ruby_block("directory resource: /var/opt/gitlab/git-data") do
params {:path=>"/var/opt/gitlab/git-data", :owner=>"git", :group=>nil, :mode=>"0700", :name=>"/var/opt/gitlab/git-data"}
action [:run]
retries 0
retry_delay 2
default_guard_interpreter :default
block_name "directory resource: /var/opt/gitlab/git-data"
declared_type :ruby_block
cookbook_name "gitlab"
recipe_name "gitlab-shell"
block #<Proc:0x000000054a99a8@/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/definitions/storage_directory.rb:27>
not_if { #code block }
end
Platform:
---------
x86_64-linux
有谁知道如何解决“断言“/var/opt/gitlab/git-data”的所有权是 git 失败”错误?我对 Docker/设置 Gitlab 还有些陌生,所以我很可能忽略了一些简单的事情。我花了几个小时在谷歌上搜索这个,似乎其他人在使用 Docker 工具箱从 Windows 上工作共享文件夹时也遇到了很多问题,所以希望这对其他人也有帮助。
【问题讨论】:
-
您是否使用了正确的 uid/gid? stackoverflow.com/a/33935328/6309
-
@VonC 我尝试使用您引用的帖子中的 uid/gid 重新挂载,但没有成功(我遇到了同样的错误)。我刚刚遇到了这个post,所以我现在在想,不可能按照我接近它的方式来做,推荐的过程是创建一个 NFS 挂载而不是使用 VirtualBox 挂载,所以这就是我接下来会尝试做的事情。
-
OK 如果您找到解决方案,请不要忘记发布答案。
-
@VonC 我还没有解决这个问题,对很多部分来说还是新的,但我在这里发布了一个关于设置 nfs 的新问题:stackoverflow.com/q/45172466/4271437
-
NFS 是一条死胡同。最后,我有一个 2 管齐下的解决方案。 1.)对于持久卷,使用位于 D 驱动器上的第二个虚拟驱动器(注意:因为 docker 机器是只读的,这看起来像是已安装,因为它位于 fstab 中,但它不会。在 docker 机器重新启动后手动安装它,或者使用正确的安装命令制作启动脚本。)。 2.) 对于备份,您可以使用简单的挂载文件夹,因为 gitlab 不需要任何特殊权限。
标签: docker virtualbox gitlab windows-server-2012-r2 docker-toolbox