In this blog post, I show you how to mount a Storage Volume to a Windows Server Container using Docker Desktop for Windows on Docker on Windows Server.
Get Started
To get started, I start with Downloading the Windows Nano Server image with PowerShell Core 6.2.
docker pull mcr.microsoft.com/powershell:nanoserver-1803
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2019/01/011219_0043_MapStorageV1.png)
Create Storage Volume
For a Docker Container to a storage volume, we need to create the volume using the Docker volume command first.
Below, I am creating a volume called psscripts
Docker volume create --name psscripts
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2019/01/011219_0043_MapStorageV2.png)
In Windows Docker stores all volumes under the path below.
C:\ProgramData\Docker\volumes
Below you can see that my volume was created under the path and it is available for me to access it
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2019/01/011219_0043_MapStorageV3.png)
Create Container and connect to the volume
Next, I use the command below to create a Container running Windows Nano Server and using the -v switch to map the image inside the container under the c:\psscripts folder.
docker run -it -v c:\programdata\docker\volumes\psscripts:c:\psscripts mcr.microsoft.com/powershell:nanoserver-1803 pwsh
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2019/01/011219_0043_MapStorageV4.png)
From inside the container I can now see the volume and access directly from the container
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2019/01/011219_0043_MapStorageV5.png)
Conclusions
Using volumes with Docker and Windows Containers is something any developer and admin need to know for lifecycle management of Containers and apps.
In this post, I used Docker Desktop 18.09 and Windows Nano Server Container image, however, the commands above also work with any Windows Server container image and Linux Containers as well.
I am running linux containers on windows machine by swithcing the docker engine to run linux containers. but i can’t able to figure out the way to map volume of the linux container with windows(host) file system. but i can map volume of the windows container with the host file system. any help…:)