linux - 为什么 Docker COPY 不会更改文件权限? (--chmod)

标签 linux docker file-permissions chmod docker-build

鉴于此 Dockerfile :

FROM docker.io/alpine

RUN mkdir test

# RUN umask 0022
COPY README /test/README
COPY --chmod=777 README /test/README-777
COPY --chmod=755 README /test/README-755

COPY FORALL /test/FORALL
COPY --chmod=777 FORALL /test/FORALL-777
COPY --chmod=755 FORALL /test/FORALL-755

RUN ls -la /test
我希望有 read , write , execute Docker 在构建过程中相应地设置权限 ( docker build ./ )。
但是最后一个命令返回
total 8
drwxr-xr-x    1 root     root          4096 Jun  9 19:20 .
drwxr-xr-x    1 root     root          4096 Jun  9 19:20 ..
-rwxrwxrwx    1 root     root             0 Jun  9 19:19 FORALL
-rwxrwxrwx    1 root     root             0 Jun  9 19:19 FORALL-755
-rwxrwxrwx    1 root     root             0 Jun  9 19:19 FORALL-777
-rw-rw-r--    1 root     root             0 Jun  9 19:19 README
-rw-rw-r--    1 root     root             0 Jun  9 19:19 README-755
-rw-rw-r--    1 root     root             0 Jun  9 19:19 README-777
未更改文件权限,也未引发错误 .
为什么不起作用?
如何解决这个问题?

最佳答案

我想通了:
旗帜--chmodnew feature from Docker Buildkit ,因此有必要通过以下方式运行构建以启用它:

DOCKER_BUILDKIT=1 docker build ./
但是,Docker为什么会吞下--chmod真的不清楚。选项没有任何错误或警告不存在的选项😕。

关于linux - 为什么 Docker COPY 不会更改文件权限? (--chmod),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67910547/

相关文章:

python - 寻找一个工作的 linux 命令行工具从 rapidshare 下载

docker - 连接两个docker-compose容器

c# - 访问 Program Files 目录中的 SQL CE 数据库

linux - Linux 中的功耗优化

linux - 安装 RPM 不会运行 .spec 中列出的所有 %install 操作

linux - 创建稀疏文件

docker - 来自守护程序 : oci runtime error: container_linux. go:262 的错误响应:

docker |显示图像名称而不是 ID

Bash:拒绝目录的重命名访问

amazon-web-services - Ec2市场Linux实例权限被拒绝(公钥)