Physical location of files persisted in docker volumes on windows docker-desktop running on Hyper-V

Prince Arora
2 min readJan 11, 2022

Scenario :

  1. Files are getting generated in a docker container.
  2. When the container is terminated all the files in the container are also getting lost.
  3. To have a persistent storage, docker volumes are created.
  4. Docker volume mounts the container file system on to host VM filesystem on which the container is running. Any files generated by the docker container are stored on the host VM. Thus the data remains intact, irrespective of the container life cycle.

Problem Statement:

Where is the location of the persistent storage on VM running on Hyper-V on windows ?

Solution with sample use case

  1. Execute the command to create the docker volume
docker volume create test_volume

2. Execute the command to generate a file in the container mounted to the volume

docker run -v test_volume:/var/opt/project bash:latest bash -c "echo Hello > /var/opt/project/file.txt"

3. Inspect the created docker volume

docker volume inspect test_volume

4. Open Hyper-V manager on windows and double click on the DockerDesktopVM

4. Inside the opened VM, navigate to /var/lib/docker/volumes. The files are persisted at this location on the VM inside the folder with volume name.

--

--

Prince Arora

IT professional | Technology enthusiast | Cloud | AWS | Docker | Machine Learning