Commit Graph

26 Commits

Author SHA1 Message Date
Austin Vazquez
853aed171b api/types/image: move image option types to client
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-08-26 15:38:44 -05:00
Derek McGowan
f74e5d48b3 Create github.com/moby/moby/v2 module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-31 10:13:29 -07:00
Derek McGowan
afd6487b2e Create github.com/moby/moby/api module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-21 09:30:05 -07:00
Derek McGowan
5419eb1efc Move container to daemon/container
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-27 14:27:21 -07:00
Paweł Gronowski
c35159ed7d c8d/manifests: Fix Content size including missing content
Content size should only include size of content that is present in the
local store.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-25 15:14:51 +01:00
Paweł Gronowski
21582b84fb c8d/list: Fix empty Manifests for some images
Fix empty `Manifests` field for multi-platform images that have no
platform blobs available locally.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-24 16:52:08 +01:00
Paweł Gronowski
4e97729f14 c8d/list: Test with SharedSize = true
For additional coverage

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-18 12:23:47 +01:00
Derek McGowan
0aa8fe0bf9 Update to containerd v2.0.2, buildkit v0.19.0-rc2
Update buildkit version to commit which uses 2.0

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-15 14:09:30 +01:00
Paweł Gronowski
90fef061ec daemon/c8d: Force c8dimages alias for containerd/images
Change all github.com/containerd/containerd/images imports to be
imported as `c8dimages`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 18:39:43 +01:00
Sebastiaan van Stijn
cd8d2c56c3 Merge pull request #48861 from vvoland/c8d-list-index
c8d/list: Return `Descriptor`
2024-11-14 21:27:45 +01:00
Paweł Gronowski
b15cd283d8 c8d/list: Return Descriptor
While the endpoint returns a detailed information about its children, it
doesn't actually expose the descriptor of the root OCI index/manifest
list.
This commits adds the target description to the returned JSON.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-13 15:02:18 +01:00
Sebastiaan van Stijn
0b2d687b06 daemon/containerd: remove redundant capturing of loop vars (copyloopvar)
daemon/containerd/image_list.go:162:3: The copy of the 'for' variable "img" can be deleted (Go 1.22+) (copyloopvar)
            img := img
            ^
    daemon/containerd/image_delete_test.go:222:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/containerd/image_list_test.go:89:3: The copy of the 'for' variable "count" can be deleted (Go 1.22+) (copyloopvar)
            count := count
            ^
    daemon/containerd/image_list_test.go:306:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/containerd/image_test.go:145:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/containerd/platform_matchers_test.go:131:4: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                tc := tc
                ^
    daemon/containerd/platform_matchers_test.go:134:5: The copy of the 'for' variable "strict" can be deleted (Go 1.22+) (copyloopvar)
                    strict := strict
                    ^
    daemon/containerd/platform_matchers_test.go:159:7: The copy of the 'for' variable "p" can be deleted (Go 1.22+) (copyloopvar)
                            p := p
                            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:13 +01:00
Paweł Gronowski
3f745f2b21 c8d/list: Extract fake service helpers
Extract to a separate file as they're also used by other files in this
package.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-22 13:28:51 +02:00
Sebastiaan van Stijn
d122ea0aea api: GET /images/json: preserve original manifest order
The `manifests` option, as used for the `--tree` option on `docker image ls`
currently sorts manifests to put those that are present first. The intent was
to present "available" images at the top of each tree, followed by images that
were not pulled.

However, there's some limitations to this. First of all, the current approach
makes the output non-deterministic as the order in which variants are pulled
determines the order in which they're presented, i.e., the last pulled variant
is returned first (I omitted some variants in the example for brevity);

Here's the result of pulling `linux/riscv64`, then pulling `linux/arm64`;

    docker pull --platform=linux/riscv64 alpine:latest
    docker image ls -a --tree

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       10.6MB         3.37MB
    ├─ linux/riscv64        80cde017a105       10.6MB         3.37MB
    ├─ linux/amd64          33735bd63cf8           0B             0B
    └─ linux/arm64/v8       9cee2b382fe2           0B             0B

    docker pull --platform=linux/arm64 alpine:latest
    docker image ls -a --tree

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       24.2MB         7.46MB
    ├─ linux/riscv64        80cde017a105       10.6MB         3.37MB
    ├─ linux/arm64/v8       9cee2b382fe2       13.6MB         4.09MB
    └─ linux/amd64          33735bd63cf8           0B             0B

Repeating the steps but in reverse order results in the output to be reversed;

    docker image rm alpine:latest
    docker pull --platform=linux/arm64 alpine:latest
    docker image ls -a --tree

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       13.6MB         4.09MB
    ├─ linux/arm64/v8       9cee2b382fe2       13.6MB         4.09MB
    ├─ linux/amd64          33735bd63cf8           0B             0B
    └─ linux/riscv64        80cde017a105           0B             0B

    docker image ls -a --tree

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       24.2MB         7.46MB
    ├─ linux/riscv64        80cde017a105       10.6MB         3.37MB
    ├─ linux/arm64/v8       9cee2b382fe2       13.6MB         4.09MB
    └─ linux/amd64          33735bd63cf8           0B             0B

The second limitation is that order sometimes matters; when matching a
platform from a manifest-index, implementations may find multiple suitable
candidates. In most cases the _most_ suitable candidate can be selected
(e.g., prefer `linux/arm/v7` over `linux/arm/v6`), but manifest-indices do
allow multiple entries for the same platform, in which case implementations
match the first entry found.

While these situations will be less common (and usually due to incorect use
of tooling such as `docker manifest`), being able to observe the order in
which manifests appeared in the index can help debugging or help the user
understand why a specific variant was selected.

We should therefore not re-order these manifests, and return them in the
order in which they appeared. If we decide to present "present" variants
before "non-present" variants, we can do this ordering on the client side.

With this patch applied;

    docker pull --quiet --platform=linux/riscv64 alpine:latest
    docker pull --quiet --platform=linux/arm64 alpine:latest
    docker image ls --tree alpine

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       24.2MB         7.46MB
    ├─ linux/amd64          33735bd63cf8           0B             0B
    ├─ linux/arm/v6         50f635c8b04d           0B             0B
    ├─ linux/arm/v7         f2f82d424957           0B             0B
    ├─ linux/arm64/v8       9cee2b382fe2       13.6MB         4.09MB
    ├─ linux/386            b3e87f642f5c           0B             0B
    ├─ linux/ppc64le        c7a6800e3dc5           0B             0B
    ├─ linux/riscv64        80cde017a105       10.6MB         3.37MB
    └─ linux/s390x          2b5b26e09ca2           0B             0B

Which matches the order of the manifests in the index:

    docker buildx imagetools inspect --raw alpine:latest | jq -c .manifests[].platform
    {"architecture":"amd64","os":"linux"}
    {"architecture":"arm","os":"linux","variant":"v6"}
    {"architecture":"arm","os":"linux","variant":"v7"}
    {"architecture":"arm64","os":"linux","variant":"v8"}
    {"architecture":"386","os":"linux"}
    {"architecture":"ppc64le","os":"linux"}
    {"architecture":"riscv64","os":"linux"}
    {"architecture":"s390x","os":"linux"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 11:59:33 +02:00
Paweł Gronowski
f4e82e2fb0 c8d/list: Don't exclude non-container images
Before this, the image list would not show images that are not a valid
container image, but could be a valid artifact.

While they're not directly usable by docker, we should still show them
so the user can still discover them and at least be able to delete them.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-29 11:56:17 +02:00
Paweł Gronowski
29a2f6d339 c8d/list: Update benchmark to also have containers
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-23 22:13:58 +02:00
Paweł Gronowski
6bb6befc37 c8d: Rename readConfig to readJSON
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-14 14:12:23 +02:00
Paweł Gronowski
495fab8e66 c8d/list: Add test for total and content size
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-14 14:12:22 +02:00
Paweł Gronowski
050afe1e1a api/list: Expose manifests
Add `Manifests` field to `ImageSummary` which exposes all image
manifests (which includes other blobs using the image media type, like
buildkit attestations).

There's also a new `manifests` query field that needs to be set in order
for the response to contain the new information.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-07 13:48:54 +02:00
Sebastiaan van Stijn
d0aa3eaccf Migrate to github.com/containerd/platforms module
Switch to use github.com/containerd/platforms module, because containerd's
platforms package has moved to a separate module. This allows updating the
platforms parsing independent of the containerd module itself.

The package in containerd is deprecated, but kept as an alias to provide
compatibility between codebases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 21:20:29 +02:00
Sebastiaan van Stijn
181101c4a8 daemon/containerd: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:47 +02:00
Paweł Gronowski
c16d676266 c8d/blobsDirContentStore: Return ErrNotExists
Translate os.ErrNotExist into cerrdefs.ErrNotExists

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:11 +02:00
Paweł Gronowski
7d95fe8db5 c8d/list: Ignore unexpected image target
Don't fail-fast when encountering an image that targets an unexpected
descriptor (neither a manifest nor index). Log a warning instead.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-04-22 12:58:46 +02:00
Paweł Gronowski
dade279565 c8d/list: Add Images benchmark
Benchmark the `Images` implementation (image list) against an image
store with 10, 100 and 1000 random images. Currently the images are
single-platform only.

The images are generated randomly, but a fixed seed is used so the
actual testing data will be the same across different executions.

Because the content store is not a real containerd image store but a
local implementation, a small delay (500us) is added to each content
store method call. This is to simulate a real-world usage where each
containerd client call requires a gRPC call.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-19 09:38:56 +01:00
Paweł Gronowski
153de36b3f c8d/list: Add empty index test case
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-18 12:50:10 +01:00
Paweł Gronowski
582de4bc3c c8d/list: Add TestImageList
Add unit test for `Images` implementation.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-07 16:25:31 +01:00