SealSkin

docker_utils

Docker host helpers: client access, self-inspection, GPUs, and images.

Everything that talks to the Docker daemon outside of a launch goes through this module so the rest of the server never creates its own client.

attributelogger
= logging.getLogger(__name__)
funcget_docker_client() -> docker.DockerClient

Return the shared Docker client, creating it on first use.

Returns

docker.DockerClient

A DockerClient connected from the environment.

funclocal_image(client, image) -> str

Return the reference this node runs an image by, pulling it through its mirror when it is not here.

paramclientdocker.DockerClient
paramimagestr

Returns

str
funcprune_dangling_images() -> None

Remove dangling images left behind by pulls.

Returns

None
func_own_container(client) -> Any | None

Return the server's own container, or None on a host or when Docker holds no container of this process.

The server's own container is the one whose host name is this process's: the container Docker knows by that name or id, else the one named sealskin exactly. A container that merely carries the name is another server's, whose mounts and sessions are not this one's to use.

paramclientdocker.DockerClient

Returns

typing.Any | None
funcown_container_name() -> str

Return the name of the server's own container, or "" on a host or when Docker does not answer.

A container's short id is its default host name and changes each time it is recreated, while its name stays, so the cluster identity of a node in Docker is taken from the name.

Returns

str
funcinspect_self_container() -> None

Discover mount mappings, ports, and network of the server's own container.

Populates state.path_prefix_map, state.discovered_api_port, state.discovered_session_port, state.discovered_network, and state.instance_name (the container's name, else the host name). The container is the one _own_container finds.

Returns

None
functranslate_path_to_host(internal_path) -> str

Map a path inside the server container to the equivalent host path.

paraminternal_pathstr

Absolute path as seen by the server process.

Returns

str

The host path when a mount prefix matches, otherwise the input.

funcread_cpu_model() -> None

Read the CPU model name from /proc/cpuinfo into state.cpu_model.

Returns

None
funcget_system_stats() -> dict[str, Any]

Return CPU model and storage usage, cached for one minute.

Returns

dict

Dictionary with cpu_model, disk_total, and disk_used.

funcscan_render_nodes() -> list[dict[str, Any]]

Return the render nodes under /sys/class/drm as GPU descriptors.

NVIDIA nodes are typed nvidia and numbered in order for the runtime's device request; every other driver is dri3.

Returns

list[dict[str, typing.Any]]
funcget_and_cache_image_metadata(image_name, force_refresh=False) -> None

Record the local digest of an image in state.image_metadata.

paramimage_namestr

Image reference such as ghcr.io/org/app:latest.

paramforce_refreshbool
= False

Re-query Docker even when a digest is cached.

Returns

None
funcpull_and_cache_image(image_name) -> None

Pull an image in the background and refresh its cached digest.

paramimage_namestr

Image reference to pull.

Returns

None