Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:23blocks OS Ai maestro Container Utils

From Leeroopedia
Knowledge Sources
Domains Containers, CLI_Wrappers
Last Updated 2026-10-26 10:00 GMT

Overview

Concrete tool for inspecting and removing Docker containers, provided by AI Maestro's `lib/container-utils.ts`.

Description

The inspectContainerStatus function queries the `docker` CLI to determine whether a container is running, stopped, missing, or the daemon is down. The removeContainer function removes a container by name (caller must stop it first). All Docker commands use `shellQuote` to prevent injection — container names are never interpolated as shell strings.

Usage

  • Call `inspectContainerStatus` to decide whether a Docker agent's container is alive.
  • Call `removeContainer` during hard-delete to free the container name slot.

Code Reference

Source Location

  • Repository: ai-maestro
  • File: lib/container-utils.ts (L39-85 inspectContainerStatus, L88-90 removeContainer)

Signature

export async function inspectContainerStatus(name: string): Promise<ContainerStatus>

export async function removeContainer(name: string): Promise<void>

type ContainerStatus =
  | 'running' | 'paused' | 'created'  // running-ish
  | 'stopped'                         // exited / dead / restarting
  | 'missing'                         // container does not exist
  | 'docker_down'                     // daemon unreachable / not installed

Import

import { inspectContainerStatus, removeContainer } from '@/lib/container-utils'

I/O Contract

Inputs

Name Type Required Description
name string Yes Docker container name

Outputs

Name Type Description
inspectContainerStatus() returns Promise<ContainerStatus> running, stopped, missing, or docker_down
removeContainer() returns Promise<void> Removes container (rejects if running without --force)

Usage Examples

import { inspectContainerStatus, removeContainer } from '@/lib/container-utils'

const status = await inspectContainerStatus('aim-sandbox-agent')
if (status === 'running') {
  // Agent is live
} else if (status === 'stopped') {
  await removeContainer('aim-sandbox-agent') // safe now
} else if (status === 'docker_down') {
  console.warn('Docker daemon is not running')
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment