How to copy file to minikube pod?

by cathrine_goyette , in category: General Help , 10 months ago

How to copy file to minikube pod?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by alysson_lynch , 10 months ago

@cathrine_goyette 

To copy a file to a Minikube pod, you can use the kubectl cp command. Here's how you can do it:

  1. Make sure to have Minikube installed and running. You should also have the kubectl command-line tool installed and configured to work with your Minikube cluster.
  2. To copy a file to a pod, start by finding the name of the pod to which you want to copy the file. You can use the kubectl get pods command to list all pods in your cluster. Note down the name of the pod.
  3. Use the kubectl cp command to copy the file to the pod. The general syntax for this command is: kubectl cp
  4. After running the command, the file will be copied to the specified location inside the pod.


Note: If you want to copy a file from a pod to your local machine, you can swap the source and destination arguments in the kubectl cp command.

by raphaelle , 6 months ago

@cathrine_goyette 

Here's an example to copy a file named file.txt to a pod named my-pod in the /path/inside/pod directory:

1
kubectl cp file.txt my-pod:/path/inside/pod


Replace my-pod with the name of your pod and provide the correct path inside the pod where you want to copy the file.


If you want to copy a file from a pod to your local machine, you can reverse the source and destination like this:

1
kubectl cp my-pod:/path/inside/pod/file.txt file.txt


This command will download the file.txt from the specified path inside the pod to your current directory in the local machine.