diff --git a/docs/man/man1/kubectl-exec.1 b/docs/man/man1/kubectl-exec.1 index 45a2f2da69f..706802a9079 100644 --- a/docs/man/man1/kubectl-exec.1 +++ b/docs/man/man1/kubectl-exec.1 @@ -19,7 +19,7 @@ Execute a command in a container. .SH OPTIONS .PP \fB\-c\fP, \fB\-\-container\fP="" - Container name + Container name. If omitted, the first container in the pod will be chosen .PP \fB\-h\fP, \fB\-\-help\fP=false diff --git a/docs/user-guide/kubectl/kubectl_exec.md b/docs/user-guide/kubectl/kubectl_exec.md index ca3303cfcbd..64c6ef46179 100644 --- a/docs/user-guide/kubectl/kubectl_exec.md +++ b/docs/user-guide/kubectl/kubectl_exec.md @@ -41,7 +41,7 @@ Execute a command in a container. Execute a command in a container. ``` -kubectl exec POD -c CONTAINER -- COMMAND [args...] +kubectl exec POD [-c CONTAINER] -- COMMAND [args...] ``` ### Examples @@ -61,7 +61,7 @@ $ kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il ### Options ``` - -c, --container="": Container name + -c, --container="": Container name. If omitted, the first container in the pod will be chosen -h, --help[=false]: help for exec -p, --pod="": Pod name -i, --stdin[=false]: Pass stdin to the container diff --git a/pkg/kubectl/cmd/exec.go b/pkg/kubectl/cmd/exec.go index 4cb2d658654..5c2d18b5091 100644 --- a/pkg/kubectl/cmd/exec.go +++ b/pkg/kubectl/cmd/exec.go @@ -53,7 +53,7 @@ func NewCmdExec(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) * Executor: &DefaultRemoteExecutor{}, } cmd := &cobra.Command{ - Use: "exec POD -c CONTAINER -- COMMAND [args...]", + Use: "exec POD [-c CONTAINER] -- COMMAND [args...]", Short: "Execute a command in a container.", Long: "Execute a command in a container.", Example: exec_example, @@ -65,7 +65,7 @@ func NewCmdExec(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) * } cmd.Flags().StringVarP(&options.PodName, "pod", "p", "", "Pod name") // TODO support UID - cmd.Flags().StringVarP(&options.ContainerName, "container", "c", "", "Container name") + cmd.Flags().StringVarP(&options.ContainerName, "container", "c", "", "Container name. If omitted, the first container in the pod will be chosen") cmd.Flags().BoolVarP(&options.Stdin, "stdin", "i", false, "Pass stdin to the container") cmd.Flags().BoolVarP(&options.TTY, "tty", "t", false, "Stdin is a TTY") return cmd