Skip to main content
Glama

exec_in_container

Execute commands inside a running Docker container, returning exit codes and output. Configure user, environment variables, working directory, and terminal allocation.

Instructions

Run a command inside a running container.

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 - Mapping with exit_code and output keys

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?

Annotations readOnlyHint=false and destructiveHint=false are not contradicted. The description explains behavior: attaching to stdout/stderr, detach, demux, and return format. It does not detail potential side effects of the command execution, but overall provides good transparency.

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 front-loaded with the core purpose and a security note, followed by a parameter list. It is slightly lengthy but well-structured. Every part adds value.

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?

For a tool with 12 parameters and no output schema, the description covers all parameters, explains return format, and includes security context. It lacks handling of edge cases like container not running, but overall is quite complete.

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?

Schema coverage is 0%, but the description lists all parameters with brief explanations, adding critical meaning (e.g., cmd should prefer exec-form, std* attach options, user, workdir, environment). This fully compensates for the missing schema 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 clearly states the verb 'Run' and resource 'container', specifying it runs a command inside a running container. This distinguishes it from sibling tools like run_container or create_container that start new containers.

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

Usage Guidelines4/5

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

The security note provides explicit guidelines on using exec-form argv to avoid shell injection when cmd is agent-controlled. It implies when to use (for running commands in a running container) but does not mention when not to use or list alternatives.

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/GavinLucas/docker-mcp'

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