Docker icon

Docker

Manage Docker containers, images, networks, volumes, and daemon metadata with Unix socket, TCP, TLS, or SSH connections

Container → Exec

AI-generated

Summary

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

Links

Discussion