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.

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!