【发布时间】:2019-11-26 02:54:46
【问题描述】:
我想在使用 setfacl 构建 docker 映像时为某些文件夹设置默认 acl,但它没有效果。默认 acl 不变。我的目标是在 /opt 中创建的每个文件都必须对任何用户都具有 rwX 权限,因为该图像稍后将使用任意 uid 运行并且需要对 /opt 的完全访问权限。
这是一个简单的 Dockerfile 示例
FROM ubuntu:bionic
SHELL ["/bin/bash", "-c"]
RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends acl > /dev/null
RUN chmod -R a+rwXs /opt
RUN setfacl -d -m o::rwx /opt
RUN getfacl /opt
输出是
# file: opt
# owner: root
# group: root
# flags: ss-
user::rwx
group::rwx
other::rwx
这是错误的,缺少默认的acl。但是,如果我手动运行容器中的命令,它就可以工作
docker run -ti --rm ubuntu:bionic bash
root@636bf8fdba41:/# apt-get update > /dev/null && apt-get install -y --no-install-recommends acl > /dev/null
debconf: delaying package configuration, since apt-utils is not installed
root@636bf8fdba41:/# chmod -R a+rwXs /opt
root@636bf8fdba41:/# setfacl -d -m o::rwx /opt
root@636bf8fdba41:/# getfacl /opt
getfacl: Removing leading '/' from absolute path names
# file: opt
# owner: root
# group: root
# flags: ss-
user::rwx
group::rwx
other::rwx
default:user::rwx
default:group::rwx
default:other::rwx
知道为什么 docker 在 Dockerfile 中运行 setfacl 时没有正确应用 acl 更改吗?
Docker 版本 19.03.5,构建 633a0ea838 Ubuntu 18.04 作为主机
【问题讨论】:
-
我用不同的方法解决了我的问题,但由于这不是我的 acl 问题的答案,我将它作为评论而不是答案发布:我在 every 命令我在 Dockerfile 中运行。看起来很讨厌,但允许任何连接到 docker 容器的 uid 使用 conda/pip 安装新包。所以基本上: RUN umask 0000 &&
如果有人知道更好的解决方案,请告诉我!
标签: linux docker ubuntu dockerfile acl