为什么我的 docker 容器不尊重我的权限?

Why isn't my docker container respecting my permissions?

Docker 文件:

FROM ubuntu:latest

RUN apt install -y bash

CMD []

构建和 运行:

docker build -t test .
docker run -it test bash

最小复制:

root@8807902e27b4:/# mkdir parent
root@8807902e27b4:/# cd parent
root@8807902e27b4:/parent# mkdir example
root@8807902e27b4:/parent# chmod 000 example
root@8807902e27b4:/parent# ls -la
total 12
drwxr-xr-x 3 root root 4096 Apr 28 19:33 .
drwxr-xr-x 1 root root 4096 Apr 28 19:32 ..
d--------- 2 root root 4096 Apr 28 19:33 example
root@8807902e27b4:/parent# cd example
root@8807902e27b4:/parent/example# echo "test" > test.txt
root@8807902e27b4:/parent/example# chmod 100 test.txt
root@8807902e27b4:/parent/example# cat test.txt
test
root@8807902e27b4:/parent/example# ls -la
total 12
d--------- 2 root root 4096 Apr 28 19:33 .
drwxr-xr-x 3 root root 4096 Apr 28 19:33 ..
---x------ 1 root root    5 Apr 28 19:33 test.txt

在上面的示例中,cd example 命令应该会失败,即使没有失败,运行ning cat test.txt 也应该会失败。有人知道怎么回事吗?

以下是 osx 中的相同(有效)命令 运行:

beaushinkle@Beaus-MBP ~/p/example-docker> mkdir parent
beaushinkle@Beaus-MBP ~/p/example-docker> cd parent
beaushinkle@Beaus-MBP ~/p/e/parent> mkdir example
beaushinkle@Beaus-MBP ~/p/e/parent> chmod 000 example
beaushinkle@Beaus-MBP ~/p/e/parent> cd example
cd: Permission denied: 'example'
beaushinkle@Beaus-MBP ~/p/e/parent [1]> chmod 777 example
beaushinkle@Beaus-MBP ~/p/e/parent> cd example
beaushinkle@Beaus-MBP ~/p/e/p/example> echo "test" > test.txt
beaushinkle@Beaus-MBP ~/p/e/p/example> chmod 100 test.txt
beaushinkle@Beaus-MBP ~/p/e/p/example> cat test.txt
cat: test.txt: Permission denied

如果提示有任何问题,我们在最小复制中以 root 身份登录。因此,我们有 root privileges and can read and write all files (external link).