Search code examples
kubernetes-helmdocker-volumepersistent-volume-claims

Copying files from docker volume to kubernetes volume


I am moving my service to kubernetes from docker and I also have to copy over some files from my docker volume.

I am using a PersistentVolumeClaim and a StorageClass in kubernetes and that's already implemented.

But now I need to copy the contents in the folder /opt/checker/dataFiles to the same mount path on kubernetes. How best to do it ? Is there a better way than copying the files into the folder inside the kubernetes container manually?


Solution

  • Apparently I couldn't find any and I ended up doing this manually:

    Copy the contents from the docker volume to you local disk (docker cp container:source_path local_dest_path)

    Copy the contents into the Kubernetes volumes into the mount path (kubectl cp local_dest_path namespace/pod:final_dest_path)