Docker run "error while creating mount source path '[...]': mkdir [...]: permission denied"

Viewed 7669

I'm trying to mount a directory in Docker run:

docker run --restart always -t -v /home/dir1/dir2/dir3:/dirX --name [...]

But I get the error:

error while creating mount source path '/home/dir1/dir2/dir3': mkdir /home/dir1/dir2/dir3: permission denied.

All the directories exist for sure, and the strange thing is when trying to mount dir2 and not dir3 it is working ok:

docker run --restart always -t -v /home/dir1/dir2/:/dirX --name [...]   # THIS IS WORKING

All the directories ('dir2' and 'dir3') have the same permissions: drwxr-x---

Any suggestions on what might be the problem? why one is working and the other don't? Thanks

1 Answers

Check the permission for the folder you're trying to mount docker with ls -la, you might need to modify the permissons with chmod.

If you don't want to modify permissions, just add sudoto the beggining of the command.

sudo docker run --restart always -t -v /home/dir1/dir2/dir3:/dirX --name [...]

Related