Skip to main content
Glama

container_exec

Execute commands inside any running Docker container, controlling user, environment, workdir, and output capture.

Instructions

Run a command inside a running container (for a compose service, prefer compose_exec).

Security: when any element of cmd is agent-controlled, use an exec-form argv list that does not invoke a shell (e.g. ["python", "-V"], ["ls", path]). A string cmd, or a shell form like ["sh", "-c", template], interprets shell metacharacters in the untrusted parts.

args: id_or_name - The container id or name cmd - Command to execute (prefer exec-form argv, no shell, when any element is agent-controlled) stdout - Attach to stdout stderr - Attach to stderr stdin - Attach to stdin tty - Allocate a pseudo-TTY privileged - Run with extended privileges user - User to run the command as detach - Detach from the exec environment - Environment variables workdir - Working directory inside the container demux - Return stdout and stderr separately returns: dict - {"exit_code", "output"}; output is combined stdout+stderr, or a [stdout, stderr] pair with demux=True

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cmdYes
ttyNo
userNo
demuxNo
stdinNo
detachNo
stderrNo
stdoutNo
workdirNo
id_or_nameYes
privilegedNo
environmentNo
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses important behavioral traits beyond the minimal annotations: security implications of shell forms, return format structure, and how stdout/stderr are combined unless demux is set. It doesn't contradict annotations (readOnlyHint=false, destructiveHint=false), and the security note adds real value. Some behavior like detach semantics could be expanded, but overall it's transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is longer than average, but well-structured: purpose, security note, args list, returns. Each section carries necessary information; the security paragraph is critical and the arg list is concise despite 12 parameters. It earns its length without being bloated.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description includes the return shape, parameter meanings, and security context, making it complete enough to invoke correctly. It doesn't explicitly cover failure conditions or edge cases, but for a Docker exec tool with no output schema, it provides sufficient operational detail. Minor gaps around detach behavior and environment variable format, but overall solid.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description carries the full burden of documenting all 12 parameters. It provides a concise args list with meaningful comments for each (e.g., demux returns stdout/stderr separately, tty allocates a pseudo-TTY), and critically explains the security-sensitive 'cmd' parameter format. This fully compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with 'Run a command inside a running container', a specific verb+resource statement that clearly distinguishes the tool from container_run (which starts a new container) and compose_exec (explicitly mentioned as preferable for compose services). The purpose is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use an alternative ('for a compose service, prefer compose_exec') and provides detailed security-driven usage guidance: use exec-form argv without shell when cmd elements are agent-controlled, and warns about shell metacharacter interpretation. This directly helps the agent decide how to invoke the tool safely and when to choose a different tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/L337-org/docker-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server