container_run
Creates and starts a Docker container from an image in one call. Run detached for background tasks or attached to capture output.
Instructions
Run a container from an image (create and start in one call, like docker run).
Use container_create to prepare a container without starting it, or container_exec to run
a command in a container that already exists. With detach=False the call blocks until the
container exits and returns its output, so long-running images need detach=True. Created
containers are stamped with provenance labels.
Args:
command: The command to run in the container
name: Name to assign to the container
detach: Run in the background and return container info
environment: Environment variables, as {"KEY": "value"} or a list of "KEY=value" strings
ports: Port mappings, e.g. {'2222/tcp': 3333}
volumes: Volumes to mount, as {"/host/path": {"bind": "/in/container", "mode": "rw"}}
or a list of "host:container:mode" strings
network: Name of the network to attach
hostname: Hostname for the container
user: Username or UID to run as
working_dir: Working directory inside the container
entrypoint: Entrypoint to override the image default
restart_policy: Restart policy, e.g. {'Name': 'on-failure', 'MaximumRetryCount': 3}
labels: Labels to set on the container
remove: Remove the container when it exits (only with detach=False)
auto_remove: Enable auto-removal of the container on daemon side
privileged: Give extended privileges to the container
tty: Allocate a pseudo-TTY
mem_limit: Memory limit: bytes as an int, or a units string ("100000b", "1000k", "128m", "1g")
cpu_count: Number of CPUs
extra_kwargs: Additional keyword arguments forwarded to ContainerCollection.run (call
docs_lookup(section="containers") for the full accepted set)
Returns: dict | str: The container's full inspect payload when detach=True, else stdout/stderr as a string
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tty | No | ||
| name | No | ||
| user | No | ||
| image | Yes | ||
| ports | No | ||
| detach | No | ||
| labels | No | ||
| remove | No | ||
| command | No | ||
| network | No | ||
| volumes | No | ||
| hostname | No | ||
| cpu_count | No | ||
| mem_limit | No | ||
| entrypoint | No | ||
| privileged | No | ||
| stdin_open | No | ||
| auto_remove | No | ||
| environment | No | ||
| working_dir | No | ||
| extra_kwargs | No | ||
| restart_policy | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |