Manage Pods
Learn how to start, stop, and manage Pods with RunPod, including creating and terminating Pods, and using the command line interface to manage your Pods.
Prerequisites
If you are using the RunPod CLI, you'll need to set your API key in the configuration.
runpodctl config --apiKey $RUNPOD_API_KEY
Replace $RUNPOD_API_KEY
with your RunPod API key.
Once your API key is set, you can manage your infrastructure.
If you're not sure which Pod meets your needs, see Choose a Pod.
Create Pods
- Web
- Command line
- Navigate to Pods and select + Deploy.
- Choose between GPU and CPU.
- Customize your an instance by setting up the following:
- (optional) Specify a Network volume.
- Select an instance type. For example, A40.
- (optional) Provide a template. For example, RunPod Pytorch.
- (GPU only) Specify your compute count.
- Review your configuration and select Deploy On-Demand.
To create a Pod using the CLI, use the runpodctl create pods
command.
runpodctl create pods \
--name hello-world \
--gpuType "NVIDIA A40" \
--imageName "runpod/pytorch:3.10-2.0.0-117" \
--containerDiskSize 10 \
--volumeSize 100 \
--args "bash -c 'mkdir /testdir1 && /start.sh'"
RunPod supports custom templates that allow you to specify your own Dockerfile. By creating a Dockerfile, you can build a custom Docker image with your specific dependencies and configurations. This ensures that your applications are reliable and portable across different environments.
Charges occur after the Pod build is complete.
Stop a Pod
- Web
- Command line
- Click the stop icon.
- Confirm by clicking the Stop Pod button.
To stop a Pod, enter the following command.
runpodctl stop pod $RUNPOD_POD_ID
Stop a Pod after a specific time
You can also stop a Pod after a specific amount of time. For example, the following command sleeps for 2 hours, and then stops the Pod.
- SSH
- Web terminal
Use the following command to stop a Pod after 2 hours:
sleep 2h; runpodctl stop pod $RUNPOD_POD_ID &
This command uses sleep to wait for 2 hours before executing the runpodctl stop pod
command to stop the Pod.
The &
at the end runs the command in the background, allowing you to continue using the SSH session.
To stop a Pod after 2 hours using the web terminal, enter:
nohup bash -c "sleep 2h; runpodctl stop pod $RUNPOD_POD_ID" &
nohup
ensures the process continues running if you close the web terminal window.
You are charged for storing idle Pods. If you do not need to store your Pod, be sure to terminate it next.
Start a Pod
You can resume a pod that has been stopped.
- Web
- Command line
- Navigate to the Pods page.
- Select your Pod you want to resume.
- Select Start.
Your Pod will resume.
To start a single Pod, enter the command runpodctl start pod
. You can pass the environment variable RUNPOD_POD_ID
to identify each Pod.
runpodctl start pod $RUNPOD_POD_ID
Terminate a Pod
Terminating a Pod permanently deletes all data outside your Network volume. Be sure you've saved any data you want to access again.
- Web
- Command line
- Select the hamburger menu at the bottom of the Pod you want to terminate.
- Click Terminate Pod.
- Confirm by clicking the Yes button.
To remove a single Pod, enter the following command.
runpodctl remove pod $RUNPOD_POD_ID
You can also remove Pods in bulk. For example, the following command terminates up to 40 pods with the name my-bulk-task
.
runpodctl remove pods my-bulk-task --podCount 40
List Pods
If you're using the command line, enter the following command to list your pods.
runpodctl get pod