[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],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/)."]]