Stay organized with collectionsSave and categorize content based on your preferences.
Executing shell commands on your container
To troubleshoot some isses, you might have to access the container to execute commands directly
on the container itself. You can access a container through abashshell or through PowerShell using thekubectl execcommand.
Usekubectl describe podsto find the name of the Pod in your cluster that you
want to connect to.
In the following example, the command lists the suitecrm-0 pod.
kubectl describe pods | grep Name
Name: suitecrm-0
Execute shell commands using one of the following methods:
Usekubectl execto open a bash command shell where you can execute commands.
kubectl exec -itpod-name-- /bin/bash
The following example gets a shell to the suitecrm-0 pod:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Executing shell commands on your container\n==========================================\n\nTo troubleshoot some isses, you might have to access the container to execute commands directly\non the container itself. You can access a container through a `bash` shell or through PowerShell using the\n[`kubectl exec` command.](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#exec)\n| **Note:** In the examples below, for PowerShell replace `/bin/bash` with `cmd.exe`, `powershell.exe`, or `pwsh.exe` depending on your version.\n\n1. Use `kubectl describe pods` to find the name of the Pod in your cluster that you want to connect to.\n\n In the following example, the command lists the suitecrm-0 pod. \n\n ```\n kubectl describe pods | grep Name\n\n Name: suitecrm-0\n ```\n2. Execute shell commands using one of the following methods:\n - Use `kubectl exec` to open a bash command shell where you can execute commands. \n\n ```\n kubectl exec -it pod-name -- /bin/bash\n ```\n\n The following example gets a shell to the suitecrm-0 pod: \n\n ```\n kubectl exec -it suitecrm-0 -- /bin/bash\n ```\n - Use `kubectl exec` to execute commands directly. \n\n ```\n kubectl exec -it pod-name -- /bin/bash -c \"command(s)\"\n ```\n\n The following example lists the root directory of the suitecrm-0 pod: \n\n ```\n kubectl exec -it suitecrm-0 -- /bin/bash -c \"ls /\"\n ```\n\nFor more information, see the\n[Kubernetes documentation](https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/)."]]