Help Center/
Cloud Container Engine/
User Guide (ME-Abu Dhabi Region)/
Workloads/
Accessing a Container
Updated on 2024-01-04 GMT+08:00
Accessing a Container
Scenario
If you encounter unexpected problems when using a container, you can log in to the container to debug it.
Logging In to a Container Using kubectl
- Use kubectl to connect to the cluster. For details, see Connecting to a Cluster Using kubectl.
- Run the following command to view the created pod:
kubectl get pod
The example output is as follows:NAME READY STATUS RESTARTS AGE nginx-59d89cb66f-mhljr 1/1 Running 0 11m
- Query the container name in the pod.
kubectl get po nginx-59d89cb66f-mhljr -o jsonpath='{range .spec.containers[*]}{.name}{end}{"\n"}'
The example output is as follows:container-1
- Run the following command to log in to the container-1 container in the nginx-59d89cb66f-mhljr pod:
kubectl exec -it nginx-59d89cb66f-mhljr -c container-1 -- /bin/sh
- To exit the container, run the exit command.
Parent topic: Workloads
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot