【发布时间】:2016-06-02 22:40:22
【问题描述】:
我有一个 docker 容器,它在容器内的用户帐户“go”下运行 GOCD 服务器(java 应用程序)。
此容器将 /etc/hosts 挂载为 644(所有用户均可读取),但“go”帐户似乎无法读取此文件。
这是证据:
[~] # docker -v
Docker version 1.10.2, build 0762ca4
# first enter the container as root and read the contents of
# /etc/hosts
~] # docker exec -it 0dac9bf0eab5 bash
root@gocd:/# ls -la /etc/hosts
-rw-r--r--+ 1 root root 164 Jun 2 22:03 /etc/hosts
#no problem - file is readable
root@gocd:/# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
10.0.3.2 gocd
root@gocd:/#
# now change user to 'go'
root@gocd:/# su - go -c bash
go@gocd:/$ id
uid=999(go) gid=999(go) groups=999(go)
# check permissions - still 644
go@gocd:/$ ls -la /etc/hosts
-rw-r--r--+ 1 root root 164 Jun 2 22:03 /etc/hosts
# but trying to read the file - causes error:
go@gocd:/$ cat /etc/hosts
cat: /etc/hosts: Permission denied
任何想法为什么会发生这种情况?
【问题讨论】:
-
我也试过了。它向我展示了 /etc/hosts。相同的权限。唯一的区别:-rw-r--r--。而不是+。 '+' 表示这是一个 ACL。检查它是否是一个 ACL: 'ls -le filename' 。摆脱 ACL 运行 echo | sudo chmod -E 文件名或 echo | sudo chmod -R -E 目录的目录名称。让我知道它是否有帮助/有效。 (如果可行,我会将其作为答案发布)。
-
你是绝对正确的 - 这是 ACL 的事情。我已经使用 'root@gocd:/# setfacl -b /etc/hosts' 删除了 ACL,并且容器内的应用程序开始工作。所以一切都很好 - 唯一的事情 - 我想避免对我创建的每个容器都这样做。我使用 QNAP 和 ContainerStation - 它是 docker 的包装器,我怀疑它是 ContainerStation,它在 /etc/hosts 上创建了一个带有 ACL 的容器。非常感谢您的想法!
-
这里是威联通论坛的相关讨论:forum.qnap.com/viewtopic.php?t=117600
-
发布您的步骤作为答案
标签: docker