Skip to content

Engine: expose image Config.Labels and inherit image labels on container create - #393

Open
maplezzk wants to merge 1 commit into
libracoder:mainfrom
maplezzk:fix/docker-inspect-labels
Open

maplezzk wants to merge 1 commit into
libracoder:mainfrom
maplezzk:fix/docker-inspect-labels

Conversation

@maplezzk

Copy link
Copy Markdown

Problem

Kiri currently omits image Labels across Docker-compatible inspect/list endpoints and container creation:

  1. GET /images/{id}/json (docker image inspect) omits Config.Labels, breaking tools/scripts that read OCI labels such as org.opencontainers.image.* or custom release metadata.
  2. GET /images/json (docker images) hardcodes "Labels": null and passes &Value::Null to Filters::labels, so docker images --filter label=... never matches.
  3. GET /system/df hardcodes "Labels": null on image rows.
  4. POST /containers/create stores only body["Labels"] without inheriting config.Labels from the base image (Docker Engine merges image labels underneath container labels).
  5. POST /commit did not persist spec.labels into the committed image config.

Changes

  • Read config["config"]["Labels"] from the stored image config blob in crates/kiri/src/daemon/api.rs (image_config_json, image_labels_from, image_labels), preserving backward compatibility with existing on-disk images.json.
  • Expose Config.Labels in image_inspect (and reuse the single config read for Healthcheck).
  • Expose Labels and support label / label! filters in GET /images/json.
  • Inherit image config.Labels underneath request Labels in POST /containers/create (merge_labels).
  • Expose real image Labels in GET /system/df and write back spec.labels in POST /commit (crates/kiri/src/daemon/ops.rs).
  • Add integration test image_and_container_labels_follow_docker covering image_inspect, images label/label! filters, and create + container_inspect label inheritance/override.

Testing

  • cargo test -p kiri --bin kiri daemon::api (20 passed, 0 failed)
  • cargo xtask host (release build + virtualization entitlement codesign succeeded)

@libracoder

Copy link
Copy Markdown
Owner

@maplezzk thanks for this. It works: image labels, the label filter and inherited container labels all checked out on macOS, Linux and WSL 2. Before it can be merged, the commit needs to be signed. Right now GitHub shows it as unsigned. Please sign it (GPG or SSH, with the key added to your GitHub account as a signing key), then force-push. GitHub's guide: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

While you're at it, please rebase onto main. #400 also edits images(), so there will be a small conflict there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants