exec command runs a shell command inside a sandbox and captures its output. The CLI exits with the same exit code as the remote command.
Running a Command
oc exec <id> -- <command...>
Executes a shell command and waits for it to complete. Everything after -- is joined into the command string.
| Flag | Type | Default | Description |
|---|---|---|---|
--cwd | string | — | Working directory for the command |
--timeout | int | 60 | Maximum execution time in seconds |
--env | string | — | Environment variable (KEY=VALUE, repeatable) |
--json): Returns the full ProcessResult object.
ProcessResult
When using--json, the output includes:
| Field | Type | Description |
|---|---|---|
exitCode | number | Exit code of the process (0 = success) |
stdout | string | Standard output |
stderr | string | Standard error |