ewok
ewok

Reputation: 21493

docker: mounting a volume with `rw` doesn't allow read/write

I'm trying to mount a volume to a docker image in read/write mode, like this:

$ 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

You can see I can't even read the directory, even though the permissions are clearly 755 for the /results directory.

Upvotes: 0

Views: 5837

Answers (1)

ewok
ewok

Reputation: 21493

I discovered the problem was I was using an outdated version of docker. I was using the old docker engine, which was replaced last year. I needed to uninstall docker then reinstall Docker CE

Upvotes: 2

Related Questions