我尝试在读/写模式下将卷安装到docker镜像,如下所示:
$ docker run -v `pwd`/results:/results:rw name-test touch /results/foo
touch: cannot touch '/results/foo': Permission denied
$ docker run -v `pwd`/results:/results:rw name-test ls -la /results
ls: cannot open directory /results: Permission denied
$ docker run -v `pwd`/results:/results:rw name-test ls -la /
total 40
drwxr-xr-x. 25 root root 4096 Mar 14 13:17 .
drwxr-xr-x. 25 root root 4096 Mar 14 13:17 ..
-rwxr-xr-x. 1 root root 0 Mar 14 13:17 .dockerenv
drwxr-xr-x. 2 root root 4096 Sep 7 2017 bin
drwxr-xr-x. 2 root root 6 Jul 13 2017 boot
drwxr-xr-x. 5 root root 340 Mar 14 13:17 dev
drwxr-xr-x. 56 root root 4096 Mar 14 13:17 etc
drwxr-xr-x. 3 root root 18 Sep 12 2017 home
drwxr-xr-x. 9 root root 123 Sep 7 2017 lib
drwxr-xr-x. 2 root root 34 Sep 7 2017 lib64
drwxr-xr-x. 2 root root 6 Sep 7 2017 media
drwxr-xr-x. 2 root root 6 Sep 7 2017 mnt
drwxr-xr-x. 207 root root 8192 Mar 14 13:14 node_modules
drwxr-xr-x. 3 root root 18 Sep 12 2017 opt
-rw-------. 1 root root 193 Mar 12 20:05 package.json
dr-xr-xr-x. 147 root root 0 Mar 14 13:17 proc
drwxr-xr-x. 2 root root 4096 Mar 12 21:22 results
drwx------. 5 root root 111 Mar 14 13:14 root
drwxr-xr-x. 4 root root 45 Mar 14 13:13 run
drwxr-xr-x. 2 root root 4096 Sep 7 2017 sbin
drwxr-xr-x. 2 root root 6 Sep 7 2017 srv
dr-xr-xr-x. 13 root root 0 Jan 17 18:45 sys
drwxrwxrwx. 4 root root 33 Mar 14 13:13 test
drwxrwxrwt. 5 root root 72 Mar 14 13:13 tmp
drwxr-xr-x. 10 root root 105 Sep 7 2017 usr
drwxr-xr-x. 11 root root 139 Sep 7 2017 var
即使/results
目录的权限明显为755,您也可以看到我甚至无法读取目录。