在Mac上使用docker安装gitlab的权限问题

问题描述 投票:5回答:5

我正在尝试让Gitlab在本地运行并遇到权限问题:

cp: cannot create regular file '/etc/gitlab/gitlab.rb': Permission denied

我正在运行的命令是

sudo docker run \
    --hostname local.gitlab \
    --publish 443:443 --publish 80:80 --publish 2200: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

如果我省略了--volumes参数,前一个命令会成功。

我试过跑步

docker exec -it gitlab update-permissions
docker restart gitlab

但这似乎也没有让事情奏效。

docker ps的输出:

CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS                            PORTS                                                            NAMES
aa0654ff45e2        gitlab/gitlab-ce:latest   "/assets/wrapper"   29 seconds ago      Up 3 seconds (health: starting)   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:2200->22/tcp   gitlab

docker logs gitlab的输出:

Thank you for using GitLab Docker Image!
Current version: gitlab-ce=10.3.2-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...
cp: cannot create regular file '/etc/gitlab/gitlab.rb': Permission denied

我在macOS Sierra 10.12.6上

任何帮助,将不胜感激!


更新

我根据this answer修改了文件夹权限,事情还有一段距离,但现在我得到了新的权限错误。以下是docker logs gitlab的输出:

Thank you for using GitLab Docker Image!
Current version: gitlab-ce=10.3.2-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

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 37: /proc/sys/fs/file-max: Read-only file system
gitlab preinstall: 
gitlab preinstall: This node does not appear to be running a database
gitlab preinstall: Skipping version check, if you think this is an error exit now
gitlab preinstall: 
Configuring GitLab...
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
- gitlab (0.0.1)
- package (0.1.0)
- registry (0.1.0)
- mattermost (0.1.0)
- consul (0.0.0)
- gitaly (0.1.0)
- runit (0.14.2)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: gitlab::default
* directory[/etc/gitlab] action create

    ================================================================================
    Error executing action `create` on resource 'directory[/etc/gitlab]'
    ================================================================================

    Errno::EPERM
    ------------
    Operation not permitted @ chmod_internal - /etc/gitlab

    Cookbook Trace:
    ---------------
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:33:in `from_file'

    Resource Declaration:
    ---------------------
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb

    28: directory "/etc/gitlab" do
    29:   owner "root"
    30:   group "root"
    31:   mode "0775"
    32:   only_if { node['gitlab']['manage-storage-directories']['manage_etc'] }
    33: end.run_action(:create)
    34: 
    35: if File.exists?("/var/opt/gitlab/bootstrapped")
    36:     node.default['gitlab']['bootstrap']['enable'] = false
    37: end
    38: 

    Compiled Resource:
    ------------------
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:28:in `from_file'

    directory("/etc/gitlab") do
    action [:create]
    retries 0
    retry_delay 2
    default_guard_interpreter :default
    path "/etc/gitlab"
    declared_type :directory
    cookbook_name "gitlab"
    recipe_name "default"
    owner "root"
    group "root"
    mode "0775"
    only_if { #code block }
    end

    Platform:
    ---------
    x86_64-linux


================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb
================================================================================

Errno::EPERM
------------
directory[/etc/gitlab] (gitlab::default line 28) had an error: Errno::EPERM: Operation not permitted @ chmod_internal - /etc/gitlab

Cookbook Trace:
---------------
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:33:in `from_file'

Relevant File Content:
----------------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:

26:  include_recipe 'gitlab::config'
27:  
28:  directory "/etc/gitlab" do
29:    owner "root"
30:    group "root"
31:    mode "0775"
32:    only_if { node['gitlab']['manage-storage-directories']['manage_etc'] }
33>> end.run_action(:create)
34:  
35:  if File.exists?("/var/opt/gitlab/bootstrapped")
36:     node.default['gitlab']['bootstrap']['enable'] = false
37:  end
38:  
39:  directory "Create /var/opt/gitlab" do
40:    path "/var/opt/gitlab"
41:    owner "root"
42:    group "root"

Platform:
---------
x86_64-linux


Running handlers:
There was an error running gitlab-ctl reconfigure:

directory[/etc/gitlab] (gitlab::default line 28) had an error: Errno::EPERM: Operation not permitted @ chmod_internal - /etc/gitlab

Running handlers complete
Chef Client failed. 0 resources updated in 05 seconds

我尝试使用/etc/gitlabGet Info修改chmod权限但没有成功。


更新第2部分

我放弃了让GL在本地运行,只是建立了一个远程开发版本。

macos docker gitlab
5个回答
6
投票

您需要做的是为尝试安装/srv/gitlab/config/srv/gitlab/logs/srv/gitlab/data的主机文件夹上的每个人授予读写权限。 Right Click > Get Info > Lock Icon

此问题与mac上的File system sharing (osxfs)以及它如何维护主机和容器之间的文件权限有关。


5
投票

使用您用户的文件夹。从某种意义上说,这将允许您绕过在外部文件夹上设置权限的需要。为我工作!

    --volume /Users/username/gitlab/config:/etc/gitlab \
    --volume /Users/username/gitlab/logs:/var/log/gitlab \
    --volume /Users/username/gitlab/data:/var/opt/gitlab \

1
投票

这看起来类似于gitlab-org/omnibus-gitlab issue 1839,它指的是更完整的指南:

Setup your own test OpenShift Origin instance for the Idea to Production Demo

那个bug仍然打开了。


0
投票

我遇到了与第一次更新后相同的问题: directory[/etc/gitlab] (gitlab::default line 28) had an error: Errno::EPERM: Operation not permitted @ chmod_internal - /etc/gitlab 我也试图'修复'权限,但无济于事。 使用所描述的默认/srv/gitlab卷时,我无法解决此问题。 只有当我将它移动到用户目录时才成功。

这可能与docker的文件共享选项有关,但我相信在我的情况下也正确配置了。


0
投票

除了在用户目录中创建文件夹。我还必须更改这些文件夹的所有权,以便它们由USERNAME而不是root拥有

所以对我有用的步骤是:

  1. 创建文件夹mkdir -p ~/srv/gitlab/data ~/srv/gitlab/config ~/srv/gitlab/logs
  2. 改变所有者sudo chown -R USERNAME:staff srv
  3. 运行容器
docker run --detach \                                                                                                                                                       
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --volume ~/srv/gitlab/config:/etc/gitlab \
  --volume ~/srv/gitlab/logs:/var/log/gitlab \
  --volume ~/srv/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest
© www.soinside.com 2019 - 2024. All rights reserved.