更改完成后,GitLab泊坞窗镜像不会重新configurationgitlab.rb中的某些参数

环境

  • 主机系统:Ubuntu 16.04 LTS
  • 主机上的Apache 2.24(带反向代理到容器)

    $ sudo docker version Client: Version: 17.06.0-ce API version: 1.30 Go version: go1.8.3 Git commit: 02c1d87 Built: Fri Jun 23 21:23:31 2017 OS/Arch: linux/amd64 Server: Version: 17.06.0-ce API version: 1.30 (minimum version 1.12) Go version: go1.8.3 Git commit: 02c1d87 Built: Fri Jun 23 21:19:04 2017 OS/Arch: linux/amd64 Experimental: false $ sudo docker info Containers: 1 Running: 1 Paused: 0 Stopped: 0 Images: 3 Server Version: 17.06.0-ce Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 30 Dirperm1 Supported: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4 init version: 949e6fa Security Options: apparmor seccomp Profile: default Kernel Version: 4.4.0-47-generic Operating System: Ubuntu 16.04.2 LTS OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 15.67GiB Name: <masked> ID: CWMI:WONN:2RZP:5HFD:GN52:BO3S:GNNW:P6WJ:5MQJ:PQLG:ZTWR:4JHM Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false 

问题

在过去的一周里,我已经拆掉了这个服务器很多次,并在我的特定设置中获取了其他各种项目。 这似乎是我第一次构build服务器时,它保存了很多我的configuration,但现在不允许我改变它。

这里是我的gitlab.rb的SMTP /电子邮件部分(与我的实际fqdn“mydomain.com”所取代:

 ### Email Settings # gitlab_rails['gitlab_email_enabled'] = true # gitlab_rails['gitlab_email_from'] = 'gitlab@mydomain.com' # gitlab_rails['gitlab_email_display_name'] = 'GitLab' # gitlab_rails['gitlab_email_reply_to'] = 'noreply@mydomain.com' # gitlab_rails['gitlab_email_subject_suffix'] = '' ### GitLab email server settings ###! Docs: https://docs.gitlab.com/omnibus/settings/smtp.html ###! **Use smtp instead of sendmail/postfix.** # gitlab_rails['smtp_enable'] = true # gitlab_rails['smtp_address'] = "mysmtp" # gitlab_rails['smtp_port'] = 587 # gitlab_rails['smtp_user_name'] = "<username>" # gitlab_rails['smtp_password'] = "<pass>" # gitlab_rails['smtp_domain'] = "mysmtp" # gitlab_rails['smtp_authentication'] = "plain" # gitlab_rails['smtp_enable_starttls_auto'] = true # gitlab_rails['smtp_tls'] = true ###! **Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert'** ###! Docs: http://api.rubyonrails.org/classes/ActionMailer/Base.html # gitlab_rails['smtp_openssl_verify_mode'] = 'none' # gitlab_rails['smtp_ca_path'] = "/etc/ssl/certs" # gitlab_rails['smtp_ca_file'] = "/etc/ssl/certs/ca-certificates.crt" 

根据GitLab的SMTP文档中的信息,我应该能够通过ruby控制台来testing发送邮件,如下所示:

 gitlab-rails console irb(main):007:0> Notify.test_email('adam@adamwgay.com', 'Message Subject', 'Message Body').deliver_now 

但是,控制台的输出是意想不到的。 我的gitlab.rb设置都不存在,它似乎使用了一些默认的选项(包括试图使用sendmail ,它在开头就吐出了一个错误)。

 irb(main):007:0> Notify.test_email('adam@adamwgay.com', 'Message Subject', 'Message Body').deliver_now Notify#test_email: processed outbound mail in 1.2ms sh: 1: /usr/sbin/sendmail: not found Sent mail to adam@adamwgay.com (5.8ms) Date: Tue, 25 Jul 2017 19:16:15 +0000 From: GitLab <gitlab@gitlab.mydomain.com> Reply-To: GitLab <noreply@gitlab.mydomain.com> To: adam@adamwgay.com Message-ID: <597798ff6423a_9593fdebe2c710863b8@gitlab.mydomain.com> Subject: Message Subject Mime-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Auto-Submitted: auto-generated X-Auto-Response-Suppress: All <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><p>Message Body</p></body></html> => #<Mail::Message:70225704413280, Multipart: false, Headers: <Date: Tue, 25 Jul 2017 19:16:15 +0000>, <From: GitLab <gitlab@gitlab.mydomain.com>>, <Reply-To: GitLab <noreply@gitlab.mydomain.com>>, <To: adam@adamwgay.com>, <Message-ID: <597798ff6423a_9593fdebe2c710863b8@gitlab.mydomain.com.mail>>, <Subject: Message Subject>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>> 

我看到这个输出有几个问题,并且告诉我gitlab.rb的SMTP设置没有正确parsing/传递给GitLab系统:

  • 此输出中的所有FromReply-To字段与我在gitlab.rb设置的字段不匹配
  • 这一行, sh: 1: /usr/sbin/sendmail: not found ,似乎表明系统仍在尝试使用sendmail。 再次,不是我在gitlab.rb设置的

进一步看来,似乎没有什么在我的gitlab.rb文件正在更新运行gitlab-ctl reconfigure然后重新启动容器。

  • 如果我直接更改设置(即使我的主机上有卷),说nginx的conf文件,然后重新启动总是恢复设置,尽pipe我已经在gitlab.rb文件中设置。
  • 如果我添加一个文件来尝试强制容器上的SMTP设置,然后重新启动删除此文件。

有没有另外一种方法来将设置从gitlab.rb到我错过的容器?

我的订单:

  1. gitlab.rb更改
  2. 运行sudo docker exec gitlab gitlab-ctl reconfigure或只是gitlab-ctl reconfigure在容器内gitlab-ctl reconfigure
  3. 运行sudo docker restart gitlabgitlab-ctl restart在容器内

即使这两种方式给我一个成功的重新configuration消息,设置不会改变。 在某种程度上,我对gitlab.rb所做的更改已经存储在容器中,因为每次重build它时,某些主机名和设置都不会改变,我的实例会很快返回所有必需的certs和HTTPS参数。 我似乎无法通过configuration文件对我的gitlab容器做任何进一步的修改。

以下是我如何构build容器,也许这是问题的一部分? 我错过了一些简单的东西吗

 sudo docker run --detach \ --hostname gitlab.mydomain.com \ --publish 10443:443 --publish 10080:80 --publish 10022:22 --publish 10587:587 --publish 10025:25 \ --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 

更新1

如果我在容器中运行gitlab-ctl diff-config ,它似乎告诉我确实有另外一个gitlab.rb,它并不是从我的/etc/gitlab/目录中的容器。 它甚至向我展示了我的configuration中的值与我在“package available config”中看到的错误值的比较。

更新2

走下去的path认为这可能是一个权限问题。 我不确定build议的所有权应该是主机系统上的任何持久卷。 我每次重新启动容器时,都将拥有root:root 。 即使我build立由root:docker所拥有的文件夹,然后重新configuration/重置,它将恢复为root:root 。 不知道是否权限是问题,但只是张贴更新信息的目的,以防止它帮助我追踪问题。

更新3

好吧,find一个非常迂回的方式来包装我的问题。 再次,我认为这只是一个gitlab.rb ,而我的gitlab.rb应该为我处理这个重新configuration,当我有时间的时候,我将不得不跟踪它。

bandaid的要点:我编辑了每个需要编辑的容器文件系统上的每个.yml和.rb文件(现在只有2个),并且使得我的服务器重build脚本如下。 我必须执行gitlab-ctl restart命令,因为重新启动整个容器将再次覆盖这两个文件。

 sudo docker run --detach \ --hostname gitlab.mydomain.com \ --publish 10443:443 --publish 10080:80 --publish 10022:22 --publish 10587:587 \ --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 sudo docker exec gitlab cp /etc/gitlab/gitlab.yml /var/opt/gitlab/gitlab-rails/etc/gitlab.yml sudo docker exec gitlab cp /etc/gitlab/smtp_settings.rb /opt/gitlab/embedded/service/gitlab-rails/config/initializers/smtp_settings.rb sudo docker exec gitlab gitlab-ctl restart 

UPDATE 4(tldr;)

我有我的configuration文件和所有参数注释掉…从我需要的,现在一切都很好。

正如@jdno指出,我有我的configuration文件参数注释掉。