I'm trying to apply kubernetes on one of my applications, and my app is using docker volumes and saves data in there. When I'm applying the kubernetes on that app it won't save any data from the docker volumes obviously and it just needs kubernetes volumes, thing is, I have my data inside the docker volumes and I need to transfer it to a kubernetes volume, and all that is running in azure and since kubernetes interfaces with azure I figured there should be a way to automate this only I couldn't find how to do that.
If someone can help with this ill be very thankful.
To transfer the data in the docker volume to Azure Kubernetes volumes, the way I can think of is that transfer the data in the docker volumes to Azure file share, and then mount the file share to the Kubernetes volumes.
The best way is that mount the Azure file share to the machine where the docker server in at the beginning, and then create the volumes in the mount path and use the volumes for your application in the docker. When you deploy the application in Azure Kubernetes, mount the file share to its volumes.
I do not think there are the interfaces in Azure Kubernetes to automate transfer the data from docker volumes to AKS volumes.
According to the kubernetes documentation: https://kubernetes.io/docs/concepts/storage/volumes/
Docker volumes
and Kubernetes volumes
are different and work differently.
When you create your PVC or it is dynamically created for you, mount it into your pod and copy the data into it using:
kubectl cp
Your app will automatically start storing data in the volume.
Docker volumes are just directories on disk and you can't simply map them to the Kubernetes volume
When I'm applying the kubernetes on that app it won't save any data from the docker volumes obviously and it just needs kubernetes volumes.
This is not fully true, as @Charles Xu mentioned, as long as your Docker containers use 'Azure File Storage' backed Volumes, you can seamlessly mount the same data volumes (Azure File Storage) as a Persistence Volumes in Azure Kubernetes Service (one of two types of data storage supported by AKS).
Taking into account you are running currently your Docker containers on-premise environment, use can use Docker Volume Driver for Azure File Storage to start pushing your data to Azure (check demo here), or for Swarm Cluster in Azure use Cloudstor.