Updated on 2025-04-18 GMT+08:00

ccictl exec

Scenario

Execute commands in a container.

ccictl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]

Examples

# Run the date command in the mypod pod to obtain the output. By default, the command is executed in the first container.
ccictl exec mypod -- date

# Run the date command in the ruby-container container of the mypod pod and obtain the output.
ccictl exec mypod -c ruby-container -- date

# Switch to the raw terminal mode, send stdin from the mypod pod to 'bash' in the ruby-container container, and send stdout/stderr from 'bash' back to the client.
ccictl exec mypod -c ruby-container -i -t -- bash -il

# List the content of /usr in the first container of the mypod pod and sort the content by modification time.
# If the command to be executed in the pod has any flag that overlaps with ccictl (for example, -i), use two hyphens (--) to separate the command's flags/arguments.
# Also note that you should not enclose your command and its flags/arguments in quotes, unless this is the way how you would execute it normally (for example, execute ls -t /usr, not "ls -t /usr").
ccictl exec mypod -i -t -- ls -t /usr

Options

-c, --container string

Container name. If the name is omitted, the kubectl.kubernetes.io/default-container annotation is used to select the container to be mounted. Otherwise, the first container in the pod is selected.

-f, --filename strings

Files used to execute the command into resources.

-h, --help

Help information for exec

--pod-running-timeout duration     Default: 1m0s

The length of time to wait until at least one pod is running (the value must be greater than 0, for example 5s, 2m, or 3h).

-q, --quiet

Print only the output of remote sessions.

-i, --stdin

Pass stdin to the container.

-t, --tty

stdin is a TTY.

The following ccictl options can also be used in subcommands:

Parent command options