kubectl exec: Execute Commands Inside Kubernetes Pods
The 'kubectl exec' command is used to execute a command inside a running container in a Kubernetes pod.
The syntax for the command is as follows:
kubectl exec [OPTIONS] POD_NAME COMMAND [ARG...]
where:
- 'POD_NAME' is the name of the pod where the container is running.
- 'COMMAND' is the command to be executed inside the container.
- '[ARG...]' are optional arguments to the command.
Some common options for 'kubectl exec' are:
- '-i' specifies that the command should be executed interactively, allowing you to input data.
- '-t' attaches a terminal to the container, allowing you to interact with it.
- '-c' specifies the name of the container to execute the command in, if the pod has more than one container.
Example usage:
kubectl exec -it my-pod -- /bin/bash
This command will open a bash shell inside the container running in the 'my-pod' pod.
原文地址: https://www.cveoy.top/t/topic/nEr2 著作权归作者所有。请勿转载和采集!