Viewing Container Image Usage

Problem

Your Connect server is configured to use off-host execution. You want to know what container images are in use by content.

Solution

Query Connect for content items and count the number of times items use each image. The result is a table, sorted by most commonly used images.

Note

The table will include only content your API key has permission to view.

from posit import connect
import polars as pl

client = connect.Client()

images_df = (pl.DataFrame(client.content.find(), infer_schema_length=None)
    .group_by("image_name").len().sort("len", descending=True))
>>> print(images_df)
shape: (4, 2)
┌─────────────────────────────────────────────────────────────────────┬─────┐
│ image_name                                                          ┆ len
------
str                                                                 ┆ u32 │
╞═════════════════════════════════════════════════════════════════════╪═════╡
│ null                                                                ┆ 45
│ ghcr.io/posit-dev/connect-content:R4.3.3-python3.11.15-ubuntu-24.0422
│ ghcr.io/posit-dev/connect-content:R4.4.3-python3.12.13-ubuntu-24.0416
│ ghcr.io/posit-dev/connect-content:R4.5.3-python3.13.13-ubuntu-24.0410
└─────────────────────────────────────────────────────────────────────┴─────┘
library(connectapi)
library(dplyr)

client <- connect()

images_df <- client |>
  get_content() |>
  count(image_name) |>
  arrange(desc(n))
> images_df
# A tibble: 4 × 2
  image_name                                                              n
  <chr>                                                               <int>
1 NA                                                                     45
2 ghcr.io/posit-dev/connect-content:R4.3.3-python3.11.15-ubuntu-24.04     22
3 ghcr.io/posit-dev/connect-content:R4.4.3-python3.12.13-ubuntu-24.04     16
4 ghcr.io/posit-dev/connect-content:R4.5.3-python3.13.13-ubuntu-24.04     10