cloud-container-engine/umn/source/workloads/accessing_a_container.rst
proposalbot 85e1a6ed92 Changes to cce_umn from docs/doc-exports#770 (Added the support of the OS for fe
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: proposalbot <proposalbot@otc-service.com>
Co-committed-by: proposalbot <proposalbot@otc-service.com>
2023-06-20 14:44:25 +00:00

1.2 KiB

original_name

cce_10_00356.html

Accessing a Container

Scenario

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

Logging In to a Container Using kubectl

  1. Use kubectl to connect to the cluster. For details, see Connecting to a Cluster Using kubectl <cce_10_0107>.

  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 name of the container 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 named container-1 in nginx-59d89cb66f-mhljrPod:

    kubectl exec -it nginx-59d89cb66f-mhljr -c container-1 -- /bin/sh
  5. To exit the container, run the exit command.