As part of my Docker coverage series and Yesterday’s post about copying Data Between A Container host And A Container, In this In this article I’ll show you how I create storage volume using Docker and attach to a running container.
When using Windows Containers It’s better not to use the storage on the container and use data volumes that keep the data on the Container Host.
By using Data Volumes the data Is visible both on the container host and on the container at the same time, also allowing us to transfer data between Host And Container.
The first thing you need to know Is that all data Volumes are stored In the path below on the Host:
To create a Data Volume type:
Docker volume create --name volume01
To view all volumes type:
Docker volume ls
To attach a Volume to a Container type:
Docker run --name test01 -it -v c:\programdata\docker\volumes\volume01:c:\volume01 windowsservercore cmd
Once you log In to the container and go to the C:\ drive you will see Volume01 which Is the data volume
To view the Data Volume details type the command below and go to the Mount section:
Docker inspect test01
Below you will see the data volume details.
You can also create multiple containers that share the same data volume.