鉴于此 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
未更改文件权限,也未引发错误 .为什么不起作用?
如何解决这个问题?
最佳答案
我想通了:
旗帜--chmod
是 new feature from Docker Buildkit ,因此有必要通过以下方式运行构建以启用它:
DOCKER_BUILDKIT=1 docker build ./
但是,Docker为什么会吞下--chmod
真的不清楚。选项没有任何错误或警告不存在的选项😕。
关于linux - 为什么 Docker COPY 不会更改文件权限? (--chmod),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67910547/