[英]Why isn't my docker container respecting my permissions?
Dockerfile:
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
命令應該會失敗,即使沒有,運行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
如果提示是 go 的任何內容,我們在最小復制中以root
身份登錄。 因此,我們擁有root 權限,可以讀取和寫入所有文件(外部鏈接) 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.