簡體   English   中英

在Mac上使用docker安裝gitlab的權限問題

[英]Permissions issue installing gitlab with docker on Mac

我正在嘗試讓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輸出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上

任何幫助,將不勝感激!


更新

我已經根據這個答案修改了文件夾權限,事情還有一段距離,但現在我得到了新的權限錯誤。 以下是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

我嘗試使用Get Infochmod修改/etc/gitlab權限但沒有成功。


更新第2部分

我放棄了讓GL在本地運行,只是建立了一個遠程開發版本。

您需要做的是為嘗試安裝/srv/gitlab/config/srv/gitlab/logs/srv/gitlab/data的主機文件夾上的每個人授予讀寫權限。 Right Click > Get Info > Lock Icon

此問題與mac上的文件系統共享(osxfs)以及它如何維護主機和容器之間的文件權限有關。

使用您用戶的文件夾。 從某種意義上說,這將允許您繞過在外部文件夾上設置權限的需要。 為我工作!

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

這看起來類似於gitlab-org / omnibus-gitlab issue 1839 ,它引用了更為完整的指南:

為Idea to Production Demo設置自己的測試OpenShift Origin實例

那個bug仍然打開了。

我遇到了與第一次更新后相同的問題:
directory[/etc/gitlab] (gitlab::default line 28) had an error: Errno::EPERM: Operation not permitted @ chmod_internal - /etc/gitlab
我也試圖'修復'權限,但無濟於事。
使用所描述的默認/srv/gitlab卷時,我無法解決此問題。
只有當我將它移動到用戶目錄時才成功。

這可能與docker的文件共享選項有關,但我相信在我的情況下也正確配置了。

除了在用戶目錄中創建文件夾。 我還必須更改這些文件夾的所有權,以便它們由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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM