Search code examples
windowsdockerfilesystemsvolume

How to configure as Docker volume a directory on the Desktop in Windows?


I started to work with Docker and I have a problem when I set a volume. I use windows OS with virtual box.

I would like to create a directory and use the as directory for the volume for a specific image.

The image is Jenkins and I would like to set as volume a directory on the desktop called volume.

I have tried a lot of commands but for the last one I tried on this:

docker run --name MyJenkins1 -v /C/Users/Alessandro/Desktop/volume:/var/jenkins_home -p 9191:8080 -p 40000:50000 jenkins

But I receive the follow result:

'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 have also tried to set the shared virtual machine directory as follow:

  1. DIRECTORY PATH: C:\Users\Alessandro\Desktop\volume
  2. DIRECTORY NAME: volume
  3. Read_only: no
  4. Auto-mount: yes
  5. Make Permanent: yes

Can somebody help me, please?

Best Regards

Alessandro


Solution

  • Does the user running Docker have permission to write to the "C:\Users\Alessandro\Desktop\volume" directory?

    If not, run this from a command line:

    set DOCKER_SHARED_DRIVE_USER=...put in the name of the OS user for docker or shared drive if using Docker Desktop...
    
    icacls "C:\Users\Alessandro\Desktop\volume" /grant %DOCKER_SHARED_DRIVE_USER%:(OI)(CI)F