kubectl ls -- or some other way to see into a POD

Greg Charles picture Greg Charles · Jan 3, 2018 · Viewed 12.8k times · Source

I'm using kubectl cp to copy a jar file from my local file system into a the home directory of a POD in my minikube environment. However, the only way I can confirm that the copy succeeded is to issue a new kubectl cp command to copy the file back to a temp directory and compare the checksums. Is there a way to view the copied files directly?

Answer

nickgryg picture nickgryg · Jan 3, 2018

You can execute commands in a container using kubectl exec command.

For example:

to check files in any folder:

kubectl exec <pod_name> -- ls -la /

or to calculate md5sum of any file:

kubectl exec <pod_name> -- md5sum /some_file