Possible to terminate pod from Within the pod?
I know you can terminate pod from “outside” with runpodctl- but are there any options for a pod to self-terminate, triggered by its own docker image?
Or, am I approaching this wrong and ‘best practice’ is to have your pods giving status updates back to and being managed by a script on your main PC w/ runpodctl?
Solution:Jump to solution
One of them is
RUNPOD_POD_ID
which you can use to remove/terminate/kill the pod.12 Replies
yes with runpodctl
A bit of a whacky idea, but what about installing runpodctl on the pod, and calling it from inside the pod, through maybe subprocess.
This may be completely wrong tho
runpodctl is preinstalled on all pods 🙂
No need for manual install
in addition to whatever custom docker image you mount on it?
Are you then able to, from a pod; read its own ID and have it kill itself?
Yes
Read what I said above
RunPod automatically injects some environment variables into a pod, with a
RUNPOD_
prefix.Solution
One of them is
RUNPOD_POD_ID
which you can use to remove/terminate/kill the pod.I see! Thanks for the clarification, I was under the assumption the ID wasnt accessible from within the pod, that it was just some handle for runpodctl to manage it from one layer above
Pod environment variables | RunPod Documentation
Configure and manage your pods with these essential environment variables, including pod ID, API key, host name, GPU and CPU count, public IP, SSH port, data center ID, volume ID, CUDA version, current working directory, PyTorch version, and public SSH key.
The template just needs to export the environment variables in order for them to be accessible everywhere, many do but not all.
I'm using my own DIY docker image, not a template, but that shouldn't be too hard to figure and add in