Exec Commands¶
Commands for executing commands in containers.
Execute Commands¶
Flags¶
| Flag | Short | Description | Default |
|---|---|---|---|
--namespace |
-n |
Target namespace | default |
--container |
-c |
Target container name | First container |
--interactive |
-i |
Keep stdin open | false |
--tty |
-t |
Allocate pseudo-TTY | false |
Examples¶
Execute a command:
Interactive shell:
Specify container in pod:
Run command with arguments:
Interactive Mode¶
When using the -it flags together:
1. Allocates a pseudo-TTY (-t)
2. Keeps stdin open (-i)
3. Provides an interactive shell session
Common interactive use cases: - Debugging container issues - Checking file contents - Testing network connectivity - Monitoring processes
Command Execution¶
The command format after -- is:
Examples:
- ls /app: List directory contents
- /bin/bash: Start interactive shell
- ps aux: List processes
- cat /etc/config: View file contents
- curl localhost:8080: Test HTTP endpoint