Docker CLI
docker exec
Starts an additional executable in an active container. Use a shell explicitly for shell operators, if installed. An exec invocation is not a persistent startup command. Choose a non-privileged diagnostic and avoid untrusted shell input. The example requires the running bm-v04-exec fixture from the lesson. The executable must exist and the container must be running and not paused; do not escalate privileges for inspection.
Formal Syntax & Structure
docker syntaxdocker
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| CONTAINER | string | Name or ID of an active container. |
| COMMAND | string | Executable to launch inside the container. |
| ARG | string[] | Arguments passed to the executable. |
| -i | flag | Keep input open. |
| -t | flag | Allocate a pseudo-terminal. |
| -w | path | Working directory for this invocation (verify API support). |
Working Example
Example Snippetdocker
docker exec bm-v04-exec echo inside