本文介绍了更改添加的文件的权限,以码头工人卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在它指出:

我们强烈建议您使用体积图像的任何可变和/或用户维修的部件。

和通过查看源$ C ​​$ c表示如 cpuguy83 / nagios的这个图片可以清楚地看到做,因为一切从到Nagios的Apache配置目录提供的卷。

And by looking at the source code for e.g. the cpuguy83/nagios image this can clearly be seen done, as everything from nagios to apache config directories are made available as volumes.

然而,看着同一图像(Nagios的和CGI的脚本)Apache服务作为默认的的nagios 用户运行。所以我现在处于困境,因为我似乎无法弄清楚如何添加自己的配置文件,以如定义的Nagios监控更多的主机。我试过:

However, looking at the same image the apache service (and cgi-scripts for nagios) are run as the nagios user by default. So now I'm in a pickle, as I can't seem to figure how to add my own config files in order to e.g. define more hosts for nagios monitoring. I've tried:

FROM cpuguy83/nagios
ADD my_custom_config.cfg /opt/nagios/etc/conf.d/
RUN chown nagios: /opt/nagios/etc/conf.d/my_custom_config.cfg
CMD ["/opt/local/bin/start_nagios"]

我建立正常,并尝试以泊坞窗运行-d -p 8000运行:80℃image_hash> ,但是我得到以下错误

错误:无法打开配置文件'/opt/nagios/etc/conf.d/my_custom_config.cfg'阅读:权限被拒绝。

果然,在文件夹中的权限样子(惠斯特apache的进程作为的nagios

And sure enough, the permissions in the folder looks like (whist the apache process runs as nagios):

# ls -l /opt/nagios/etc/conf.d/
-rw-rw---- 1 root root 861 Jan  5 13:43 my_custom_config.cfg

现在,,但比改变原来Dockerfile其他没有妥善的解决方案已被提出。

Now, this has been answered before (why doesn't chown work in Dockerfile), but no proper solution other than "change the original Dockerfile" has been proposed.

说实话,我觉得有一些在这里核心理念,我还没有掌握(因为我看不到声明配置目录的数量还是比为根以外的其他正在运行的服务点) - 因此提供了一个Dockerfile如上(这通过添加多个卷如下泊坞最佳做法)是解决/问题:

To be honest, I think there's some core concept here I haven't grasped (as I can't see the point of declaring config directories as VOLUME nor running services as anything other than root) - so provided a Dockerfile as above (which follows Docker best practices by adding multiple volumes) is the solution/problem:


  • 要改变NAGIOS_USER / APACHE_RUN_USER到根,并运行一切,根源在哪里?

  • 要删除该Dockerfile音量的声明Nagios的?

  • 其他办法?

你会如何延长 dockerfile配置文件?

How would you extend the nagios dockerfile above with your own config file?

推荐答案

既然你是直接添加自己的my_custom_config.cfg文件转换成在构建时容器只是改变你的主机上的my_custom_config.cfg文件的权限,然后使用泊坞窗构建建立你的形象。主机的权限将被复制到容器的形象。

Since you are adding your own my_custom_config.cfg file directly into the container at build time just change the permissions of the my_custom_config.cfg file on your host machine and then build your image using docker build. The host machine permissions are copied into the container image.

这篇关于更改添加的文件的权限,以码头工人卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 19:05