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

标签 docker docker-compose gitlab synology

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

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

Ran /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions returned 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] INFO: Running queued delayed notifications before re-raising exception [2019-02-10T08:15:49+00:00] ERROR: Running exception handlers [2019-02-10T08:15:49+00:00] ERROR: Exception handlers complete [2019-02-10T08:15:49+00:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out [2019-02-10T08:15:49+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report [2019-02-10T08:15:49+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: execute[/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions] (gitlab::gitlab-shell line 101) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1' ---- Begin output of /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions ---- 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 open' from /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 new' from /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' from /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 require' from /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys:24:in `' ---- End output of /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions ---- Ran /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions returned 1

最佳答案

我复制了您的设置, docker 日志(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文件夹是 super 用户文件夹。

您为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

关于docker - 如何配置docker-compose卷访问授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54614682/

相关文章:

continuous-integration - 基于正则表达式的规则子句在 GitLab CI 中不起作用

apache - docker httpd :alpine image exits with code 1

windows - 如何在Windows中为Docker容器设置静态IP地址?

git - 自托管存储库的优点(和缺点)是什么(换句话说 : GitLab vs Bitbucket)?

gitlab - 如何将 gitlab-ci.yml 文件移出存储库

nginx - 让我们加密失败的授权过程 - docker

java - 无法从另一个docker容器连接到docker容器中的mysql

docker - 我可以将kubernetes放在docker容器中吗?

docker - 容器可以继续运行吗?

go - 使用 docker 在本地运行链码时遇到问题