Actions42
- Container Actions
- Image Actions
- Network Actions
- System Actions
- Volume Actions
Container → Exec
AI-generatedSummary
Run a command inside a container using docker exec.
Inputs
- containerId (required) — Container name or short/full ID
- execCommandArgs (required) — Array of argument strings for the command to execute
- execWorkingDir — Working directory inside the container for the command
- execUser — User (uid[:gid]) to run the command as
- execTty — Allocate a pseudo-TTY
- execPrivileged — Run container in privileged mode
- execAttachStdout — Attach stdout to the client
- execAttachStderr — Attach stderr to the client
- execEnv — Array of environment variable name/value pairs
- execAllowList — Allowed command names; leave empty to allow all
- execDenyList — Denied command names; overrides allow list
Output shape
JSON object with exitCode (int), stdout (string), and stderr (string)
The object may also include 'status' indicating success; fields are optional except exitCode.
Examples
Example 1: Execute a shell command inside a running container
containerId: 'my-web', execCommandArgs: ['/bin/sh','-c','echo Hello'], execAttachStdout: true, execAttachStderr: true
Example 2: Run a privileged command as root with environment variables
containerId: 'db', execCommandArgs: ['psql','-c','SELECT 1'], execUser: 'root', execEnv: [{'name':'PGPASSWORD','value':'secret'}], execPrivileged: true