如何配置docker-compose卷访问授权

时间:2019-02-10 08:30:18

标签: docker docker-compose gitlab synology

我正在尝试根据documentation在我的Synology NAS上安装带有docker的gitlab和我自己的docker-compose.yml文件

当我在Synology上(带有终端)运行此文件时,退出代码1时出现错误:

  

Ran / opt / gitlab / embedded / service / gitlab-shell / bin / gitlab-keys   返回检查权限1

我如何配置目录或docker-compose文件以更正此错误?

我已经在数据,日志和配置上执行了chmod -R 777chown -R root:root

web:
   image: 'gitlab/gitlab-ce:latest'
   restart: always
   hostname: 'gitlab.example.com'
   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

容器退出失败(返回1),错误如下:

  

[2019-02-10T08:15:49 + 00:00]信息:运行排队的延迟通知   重新引发异常之前[2019-02-10T08:15:49 + 00:00]错误:正在运行   异常处理程序[2019-02-10T08:15:49 + 00:00]错误:异常   处理程序完成[2019-02-10T08:15:49 + 00:00]致命:Stacktrace已转储   到/opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out   [2019-02-10T08:15:49 + 00:00]致命:请提供以下内容   如果您提交错误报告,请添加stacktrace.out文件   [2019-02-10T08:15:49 + 00:00]致命:   Mixlib :: ShellOut :: ShellCommand失败:   执行[/ opt / gitlab / embedded / service / gitlab-shell / bin / gitlab-keys   检查权限](gitlab :: gitlab-shell第101行)发生错误:   Mixlib :: ShellOut :: ShellCommandFailed:预期进程退出   [0],但收到“ 1”   ----开始输出/ opt / gitlab / embedded / service / gitlab-shell / bin / gitlab-keys   检查权限---- STDOUT:STDERR:   /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_logger.rb:30:in   从initialize': Permission denied @ rb_sysopen - /var/log/gitlab/gitlab-shell/gitlab-shell.log (Errno::EACCES) from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_logger.rb:30:in 打开   /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_logger.rb:30:in   来自initialize' from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_logger.rb:120:in 的新消息   /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_logger.rb:120:in   来自的<top (required)>' from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_keys.rb:4:in require_relative'   /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_keys.rb:4:in   <top (required)>' from /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys:24:in 要求'   / opt / gitlab / embedded / service / gitlab-shell / bin / gitlab-keys:24:in   ''   ----最终输出/ opt / gitlab / embedded / service / gitlab-shell / bin / gitlab-keys   检查权限----冉   / opt / gitlab / embedded / service / gitlab-shell / bin / gitlab-keys   返回检查权限1

1 个答案:

答案 0 :(得分:0)

我已经复制了您的设置,泊坞窗日志(web_container_id)给出的最后一个输出是

=> /var/log/gitlab/gitlab-rails/sidekiq_exporter.log <==
[2019-02-11 17:16:20] 127.0.0.1 - - [11/Feb/2019:17:16:20 UTC] "GET /metrics HTTP/1.1" 200 1298 "-" "Prometheus/2.5.0"

您的问题与从执行docker的用户访问目录有关,因为它继承了文件夹和/ srv文件夹的权限,它是超级用户文件夹。

您为Linux上的Docker安装进行了以下配置吗?

https://docs.docker.com/install/linux/linux-postinstall/

除此之外,您需要确保,执行docker-compose的用户可以访问您的主机目录,此后,该目录也将不起作用。您说过在chmod 777之后使用 chown -R root:root 吗?如果没有root用户运行,将不会产生任何影响。

Dockerfile:

version: "3"
services:
  web:
   image: gitlab/gitlab-ce:latest
   restart: always
   hostname: gitlab.example.com
   environment:
     GITLAB_OMNIBUS_CONFIG: |
       external_url 'https://gitlab.example.com'
   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