Docker Community Forums

Share and learn in the Docker community.

Volumes not creating correctly for docker windows, how to fix that?

docker image pull mcr.microsoft.com/windows/servercore:ltsc2019

mkdir c:\data

cd c:\

docker run -it -v data:c:\data  mcr.microsoft.com/windows/servercore:ltsc2019

But it is using C:\ProgramData\docker\volumes\data_data\ folder of host machine instead of direct c:\data

Any suggestions on how to make it use direct c:\data

Your expectation does not match the volume declaration you specified in the docker run command.
Try docker run -it -v c:\data:c:\data mcr.microsoft.com/windows/servercore:ltsc2019 instead.

Also, you might want to take a look at this blog post:

-v c:\data:c:\data
This is not working as I am getting error as path not found.
So, that’s why, I kept the current directory as c:\ drive, sorry for the typo.

Choose whale menu > Troubleshoot from the menu bar to see the troubleshoot options.

Uninstall or reset Docker

The Troubleshoot page contains the following options:

Restart Docker Desktop: Select to restart Docker Desktop.

Run Diagnostics: Select this option to diagnose any issues on Docker Desktop. For detailed information about diagnostics, see Diagnose problems, send feedback, and create GitHub issues.

Clean / Purge data: Select this option to delete container and image data. Choose whether you’d like to delete data from Hyper-V, WSL 2, or Windows Containers and then click Delete to confirm.

Reset Kubernetes cluster: Select this option to delete all stacks and Kubernetes resources. For more information, see Kubernetes.

Reset to factory defaults: Choose this option to reset all options on Docker Desktop to their initial state, the same as when Docker Desktop was first installed.

I am running on server 2019.
You will install docker using powershell commands there.

Install-WindowsFeature -Name Containers

Uninstall-WindowsFeature Windows-Defender

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Install-Package -Name docker -ProviderName DockerMsftProvider -Force -RequiredVersion 19.03

Restart-Computer -Force

And I tested on multiple machines, so it is not an environment issue.

You need to specify the full path of the bind-mounted Windows folder and use Linux-format:

-v /c/data:/c/data

As I mentioned in 2nd comment, Full path is not supporting, that’s why I made c:\data ad current working directory and running command from there.

As far as I’m aware, Docker for Windows requires a fully-qualified path (unless you use Docker Compose which translates relative paths for you). And you certainly cannot use Windows paths with colons in them!