Search code examples
kuberneteskubectlkubernetes-pod

error: one of src or dest must be a remote file specification


I'm trying to move local folder into kubernetes volume by following command:

kubectl cp /* mynamespace/mypod-xxxx-xxxx:/var/www/my-content

Unfortunately, I got following error message:

error: one of src or dest must be a remote file specification

even I've configured volume mount as follow:

      volumeMounts:
        - mountPath: "/var/www/my-content"
          name: mycontent
  volumes:
    - name: mycontent
      persistentVolumeClaim:
        claimName: mypvc

Please let me know which I missed something to configure it.


Solution

  • There is an issue in * which is not currently supported by kubectl cp. To solve this issue just remove * and use the full directory name like

    kubectl cp /folder_name/ mynamespace/mypod-xxxx-xxxx:/var/www/my-content
    
    

    but in this case a folder will be created like /var/www/my-content/folder_name. you have to adjust this in your code or you can name your local folder name like my-content and copy to /var/www/.