Files
doc-exports/docs/cce/umn/cce_10_00356.html
qiujiandong1 bfc6e41869 CCE UMN update 20241130 version
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: qiujiandong1 <qiujiandong1@huawei.com>
Co-committed-by: qiujiandong1 <qiujiandong1@huawei.com>
2025-02-24 12:45:02 +00:00

2.8 KiB

Logging In to a Container

Scenario

If you encounter unexpected problems when using a container, you can log in to the container to debug it.

Notes and Constraints

When using CloudShell to access a CCE cluster or container, you can open a maximum of 15 instances simultaneously.

Using kubectl

  1. Use kubectl to access the cluster. For details, see Connecting to a Cluster Using kubectl.
  2. 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

  3. 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

  4. 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

  5. To exit the container, run the exit command.