quickstart.container#

Container lifecycle management using Docker SDK.

Module Contents#

Classes#

ContainerManager

Manages the nmp-api container lifecycle using Docker SDK.

PullProgress

Progress update from image pull operation.

API#

class quickstart.container.ContainerManager(config: quickstart.config.QuickstartConfig)#

Manages the nmp-api container lifecycle using Docker SDK.

This class handles: - Container creation and startup - Image pulling with authentication - Volume mounting (Docker socket for DOOD, data volume) - Environment variable configuration - Container lifecycle (start, stop, destroy) - Status and log retrieval

Initialization

Initialize container manager.

Parameters:

config – Quickstart configuration.

property client: docker.DockerClient#

Get or create Docker client.

destroy() None#

Stop container and remove all data.

This performs a complete cleanup including: - Stopping and removing the container - Removing the storage directory

get_effective_config() quickstart.config.QuickstartConfig#

Return QuickstartConfig from the running container, or self.config as fallback.

Uses Docker inspect data when the container is running so that status and cluster_info reflect reality even if the config file has drifted.

is_image_available() bool#

Check if the container image is available locally.

Returns:

True if the image exists locally, False otherwise.

logs(
follow: bool = False,
tail: int | None = 100,
) collections.abc.Iterator[str]#

Stream container logs.

Parameters:
  • follow – Keep following log output.

  • tail – Number of lines to show from the end, or None for all logs.

Yields:

Log lines as strings.

pull_image_with_progress(
auth_override: dict[str, str] | None = None,
) collections.abc.Iterator[quickstart.container.PullProgress]#

Pull the container image with progress updates.

Yields progress updates as the image is pulled. Skips if image already exists locally.

Yields:

PullProgress dictionaries with status, progress bar, and layer ID.

static reconstruct_config_from_container(
container: docker.models.containers.Container,
) quickstart.config.QuickstartConfig#

Reconstruct QuickstartConfig from a running container’s inspect data.

Parameters:

container – The running Docker container.

Returns:

QuickstartConfig populated from container inspect data.

start(
platform_config: quickstart.platform_config.PlatformConfig | None = None,
pull: bool = True,
detach: bool = True,
) docker.models.containers.Container#

Start the nmp-api container.

Parameters:
  • platform_config – Platform configuration for the container. Uses default if not provided.

  • pull – Pull the container image before starting.

  • detach – Run container in detached mode.

Returns:

The started Container object.

Raises:

docker.errors.APIError – If Docker operations fail.

status() dict#

Get container status information.

Returns:

  • running: bool

  • status: str (container state)

  • id: str (short container ID)

  • name: str

  • image: str

  • ports: dict

  • health: str (health check status)

Return type:

Dictionary with status information including

stop(remove: bool = False, timeout: int = 30) None#

Stop the nmp-api container, then model deployments, then optionally remove the network.

Stops the main quickstart container first so the models controller does not see model deployment containers in ‘stopping’ state and mark them as ERROR. Then stops and removes all remaining containers with the managed-by=models-controller (model deployments). When remove=True, also removes the main container and the quickstart network and clears the stored container ID.

Parameters:
  • remove – If True, remove the main container (if present), remove the quickstart network, and clear the stored container ID from config.

  • timeout – Seconds to wait for each container to stop gracefully.

class quickstart.container.PullProgress#

Bases: typing.TypedDict

Progress update from image pull operation.

Initialization

Initialize self. See help(type(self)) for accurate signature.

current: int | None#

None

layer_id: str | None#

None

progress: str | None#

None

status: str#

None

total: int | None#

None