modal container

Manage and connect to running containers.

Usage:

Options:

  • --help: Show this message and exit.

Commands:

  • list: List all containers that are currently running.
  • logs: Fetch or stream logs for a specific container.
  • exec: Execute a command in a container.
  • stop: Stop a currently-running container and reassign its in-progress inputs.

List all containers that are currently running.

Usage:

Options:

  • --app-id TEXT: List containers running for a specific App.
  • -e, --env TEXT: Environment to interact with.

If not specified, Modal will use the default environment of your current profile, or the MODAL_ENVIRONMENT variable. Otherwise, raises an error if the workspace has multiple environments.

  • --json / --no-json: [default: no-json]
  • --help: Show this message and exit.

Fetch or stream logs for a specific container.

By default, this command fetches the last 100 log entries and exits. Use -f to live-stream logs from a running container instead. Fetch and follow are mutually exclusive.

Examples:

Get recent logs for a container:

Follow (stream) logs from a running container:

Fetch logs from the last 2 hours:

Fetch logs in a specific time range:

Fetch the last 1000 entries:

Fetch all container logs:

Usage:

Arguments:

  • CONTAINER_ID: Container ID [required]

Options:

  • -f, --follow: Stream log output until Container stops
  • --all: Show all logs for the container
  • --since TEXT: Start of time range. Accepts ISO 8601 datetime or relative time, e.g. ‘1d’ (1 day ago), ‘2h’, ‘30m’, etc.
  • --until TEXT: End of time range; accepts same argument types as —since
  • -n, --tail INTEGER: Show only the last N log entries
  • --search TEXT: Filter by search text
  • -s, --source TEXT: Filter by source: ‘stdout’, ‘stderr’, or ‘system’
  • --timestamps: Prefix each line with its timestamp
  • --help: Show this message and exit.

Execute a command in a container.

Usage:

Arguments:

  • CONTAINER_ID: Container ID [required]
  • COMMAND...: A command to run inside the container.

To pass command-line flags or options, add -- before the start of your commands. For example: modal container exec <id> -- /bin/bash -c 'echo hi' [required]

Options:

  • --pty / --no-pty: Run the command using a PTY.
  • --help: Show this message and exit.

Stop a currently-running container and reassign its in-progress inputs.

This will send the container a SIGINT signal that Modal will handle.

Usage:

Arguments:

  • CONTAINER_ID: Container ID [required]

Options:

  • --help: Show this message and exit.