Docker Community Forums

Share and learn in the Docker community.

Authorization on volume

Expected behavior

If a volume is read/write, then any user of my container can write in this volume.

Actual behavior

Only root of container can write in this volume.


All files are :

-rwxr-xr-x 1 root root 7 Apr 4 09:09 essai.txt

And cannot change this authorization. It’s same problem with virtualbox.
rsync is remaining the best solution ?
It’s big problem for database container

Steps to reproduce the behavior

docker run -it -v ./data:/var/lib/mysql mysql

Excellent find, I’ve created an issue to track and will get back to you once we address the problem.

Thanks for helping us test D4W!

Hi @fpellet

thanks for the feedback. This should hopefully be fixed in the next Beta update.

1 Like

@fpellet This should be fixed in beta-6, I just tested to verify

What command should be used for read write access? I am trying “rw” flag but only root has write permissions. here is command and output

C:>docker run --rm -v c:/data:/data:rw alpine ls -lart /data
total 5
-rwxr-xr-x 1 root root 18 May 19 18:49 testfile.txt
drwxr-xr-x 2 root root 0 May 19 19:38 .
drwxr-xr-x 24 root root 4096 May 23 19:14 …

@vinayagg you should be running as the root user - are you finding that not to be the case?

docker run --rm alpine whoami

Michael, not all dockers run as root (and should not). Try the following:

docker run -d -name jenkins jenkins
docker exec -it jenkins

It runs under a user called “jenkins”

But on another note: in the example I gave, even though it shows only root has permissions, I was able to write using jenkins user. I am not sure why, this also seems wrong. But for now it works.

So somehow it worked for me on "docker for windows"
But now I am having same issue on “boot2docker” with windows 7.

Here is the problem -
Jenkins official docker has jenkins running under user "jenkins"
It is not able to write to any mounted volumes as mounted volumes are read only.
Here is a command that you can try

docker run --name jenkins --privileged=true -t -i --rm -p 49001:8080 -v //c/:/var/jenkins_home/:rw -v /var/run/docker.s
ock:/var/run/docker.sock -v /usr/lib64/ -v /usr/bin/docker:/bin/docker -t jenkins
touch: cannot touch /var/jenkins_home/copy_reference_file.log: Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?

I am also getting below error:

touch: cannot touch ‘/var/jenkins_home/copy_reference_file.log’: Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?

Image: jenkins:2.32.2-alpine