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

NameTypeDescription
CONTAINERstringName or ID of an active container.
COMMANDstringExecutable to launch inside the container.
ARGstring[]Arguments passed to the executable.
-iflagKeep input open.
-tflagAllocate a pseudo-terminal.
-wpathWorking directory for this invocation (verify API support).

Working Example

Example Snippetdocker
docker exec bm-v04-exec echo inside
Docker Reference