-
Notifications
You must be signed in to change notification settings - Fork 18.8k
api/image/list: Return Containers
count
#50146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Filters: imageFilters, | ||
SharedSize: sharedSize, | ||
Manifests: manifests, | ||
ContainerCount: containerCount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISTR we had a discussion to (as alternative) list the IDs of containers instead of just a count. That could make the information more actionable (not just "if it's in use, and by how many", but also being able to discover which containers are using this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, something to consider. For now just rebased the last PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Right I just read the cli ticket, and we did do that, but it's in the manifests; could we somehow construct a manifest in the non-containerd case (in which we can put the container ID)?
[
{
"Containers": -1,
"Created": 1749073960,
"Id": "sha256:f1f9df63a741c97c5b4b02c12ec89e4864774185c333d366eb3b50d9f82cf267",
"Labels": {
"org.opencontainers.image.source": "https://github.com/burgerdev/weird-images"
},
"ParentId": "",
"Descriptor": {
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:f1f9df63a741c97c5b4b02c12ec89e4864774185c333d366eb3b50d9f82cf267",
"size": 856
},
"Manifests": [
{
"ID": "sha256:8e9bc7f8de6ac3d86a483310f6fe31c1de68b128af06215fdf28a969cba1b4f0",
"Descriptor": {
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:8e9bc7f8de6ac3d86a483310f6fe31c1de68b128af06215fdf28a969cba1b4f0",
"size": 1045,
"platform": {
"architecture": "arm64",
"os": "linux"
}
},
"Available": true,
"Size": {
"Content": 1847842,
"Total": 6054434
},
"Kind": "image",
"ImageData": {
"Platform": {
"architecture": "arm64",
"os": "linux"
},
"Size": {
"Unpacked": 4206592
},
"Containers": [
"48f88941ddbdcda83b147ae7c08b1e8a6007bfb780b85920455c734635c933db"
]
}
},
{
"ID": "sha256:aa257ed292b265869388405afec449cec0a4dc67fc8127bcc206de19dd919277",
"Descriptor": {
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:aa257ed292b265869388405afec449cec0a4dc67fc8127bcc206de19dd919277",
"size": 566,
"annotations": {
"vnd.docker.reference.digest": "sha256:8e9bc7f8de6ac3d86a483310f6fe31c1de68b128af06215fdf28a969cba1b4f0",
"vnd.docker.reference.type": "attestation-manifest"
},
"platform": {
"architecture": "unknown",
"os": "unknown"
}
},
"Available": true,
"Size": {
"Content": 2084,
"Total": 2084
},
"Kind": "attestation",
"AttestationData": {
"For": "sha256:8e9bc7f8de6ac3d86a483310f6fe31c1de68b128af06215fdf28a969cba1b4f0"
}
}
],
"RepoDigests": [
"test@sha256:f1f9df63a741c97c5b4b02c12ec89e4864774185c333d366eb3b50d9f82cf267"
],
"RepoTags": [
"test:latest"
],
"SharedSize": -1,
"Size": 6056518
}
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... I guess we can't because we won't have the OCI digest etc 🤔 😢
37209f7
to
59d3bb6
Compare
Quick summary of a discussion we had earlier Today;
The goal ultimately is to change the IMAGE ID DISK USAGE CONTENT SIZE EXTRA
ubuntu:24.04 a0e45e2ce6e6 78.1MB 0B U
nginx:alpine 6769dc3a703c 48.2MB 0B
<untagged> 0fa55949643d 1.18GB 0B U
alpine:latest aded1e1a5b37 7.83MB 0B We don't want the CLI to be responsible for "detecting" if the containerd image-store is used, or not, and having a field that's available regardless if the underlying variants are shown is useful for this. Having a |
For graphdrivers, the container count need some extra cycles (it shouldn't be much though): moby/daemon/images/image_list.go Lines 201 to 216 in b5d26e5
For containerd, we already have that number anyway because we need it for moby/daemon/containerd/image_list.go Lines 413 to 415 in b5d26e5
Considering that the WDYT? |
393e7d1
to
5ac634d
Compare
container-count
parameterContainers
count
60ae6ab
to
3b56444
Compare
@@ -2195,9 +2195,6 @@ definitions: | |||
description: | | |||
Number of containers using this image. Includes both stopped and running | |||
containers. | |||
|
|||
This size is not calculated by default, and depends on which API endpoint | |||
is used. `-1` indicates that the value has not been set / calculated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1
indicates that the value has not been set / calculated.
We could keep this; even though we no longer return by default, but to explain it could be
7ad4213
to
ccb3151
Compare
This parameter was already supported for some time in the backend (for purposes related to docker system prune). It was also already present in the imagetypes.ListOptions but was never actually handled by the client. Make it available by default in the response. Signed-off-by: Paweł Gronowski <[email protected]>
ccb3151
to
cfcbfab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Hmm interesting failure, haven't seen that one before:
https://github.com/moby/moby/actions/runs/15631616328/job/44037276284?pr=50146#step:7:1277 |
Initially thought if it would be related to those locking changes, but we didn't merge it yet; |
Yeah me too! |
needs: api: bump to 1.51 #50145
replaces: api/image/list: Add
container-count
parameter #47501related to: Add support for
shared-size
parameter for images queries #42531needed by:
docker images --tree
doesn't show "Used" badge with graphdrivers docker/cli#6122This parameter was already supported for some time in the backend (for purposes related to
docker system prune
).It was also already present in the
imagetypes.ListOptions
but was never actually handled by the client.Make it available by default in the response.
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)