Commit Graph

391 Commits

Author SHA1 Message Date
bb0ca9f9ef image rm: add --platform option
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-27 10:58:11 +02:00
4665398a06 vendor: github.com/docker/docker 7937f0846c13 (master, v28.x dev)
full diff: 4b9f0707a0...7937f0846c

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 14:07:50 +02:00
214d2bfb6b cli/command/image: remove errdefs uses
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 20:30:00 +02:00
557cabb71e switch to github.com/containerd/errdefs for error-matching
replace uses of docker/errdefs.IsXXX utilities with their containerd/errdefs
equivalent.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 15:27:43 +02:00
d0d8d1dc72 cli/internal/jsonstream: move to top-level "internal"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-06 20:04:21 +02:00
22a573649d cli/command: change uses of ListOpts.GetAll for GetSlice
The `GetSlice()` function is part of cobra's [cobra.SliceValue] interface,
and duplicates the older `GetAll()` method. This patch changes our use
of the `GetAll()` method with the intent to deprecated it in future.

[cobra.SliceValue]: https://pkg.go.dev/github.com/spf13/cobra@v1.9.1#SliceValue

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-23 13:51:37 +02:00
1d768f8983 update go:build tags to go1.23 to align with vendor.mod
Go maintainers started to unconditionally update the minimum go version
for golang.org/x/ dependencies to go1.23, which means that we'll no longer
be able to support any version below that when updating those dependencies;

> all: upgrade go directive to at least 1.23.0 [generated]
>
> By now Go 1.24.0 has been released, and Go 1.22 is no longer supported
> per the Go Release Policy (https://go.dev/doc/devel/release#policy).
>
> For golang/go#69095.

This updates our minimum version to go1.23, as we won't be able to maintain
compatibility with older versions because of the above.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 10:43:47 +02:00
e7a091eceb vendor: github.com/moby/go-archive v0.1.0
full diff: https://github.com/moby/go-archive/compare/21f3f3385ab7...v0.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-16 13:08:08 +02:00
6aa93d1f40 Merge pull request #5952 from thaJeztah/move_prompt_utils_step1
cli/command: move prompt utilities to separate package
2025-04-11 16:11:12 +02:00
0d9d187f31 image/inspect: Add --platform flag
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-11 15:53:41 +02:00
f18e239a53 docker images --tree: hide both untagged and dangling images by default
Before this patch, `docker image ls` / `docker image ls` would always
show untagged images, but hide "dangling" images (which effectively
only were produced by the legacy builder) unless `-a` / `--all` was
used. This often resulted in many `<none>:<none>` or `<untagged>` images
to be shown, which had little value to interact with, other than to
garbage collect (`docker system prune`).

In future, we want to take more advantage of containerd's garbage-collecting
features (removing unused images automatically), and this UX change is
a stepping stone toward that.

For now, this patch only changes the behavior for `docker image ls --tree`,
but we should make this the same for "non" --tree as well.

This patch:

- changes `docker image ls` to hide both "untagged" and "dangling" images
  by default.
- changes the behavior of `--all` on the client side to make them visible

The API response remains the same for now, but this is something we can
consider changing in future (possibly more granular than a single boolean).

Before this patch;

    docker image ls --tree
                                                                           i Info →   U  In Use

    IMAGE                                      ID             DISK USAGE   CONTENT SIZE   EXTRA
    docker:cli                                 28fb556c1ea1        276MB         69.8MB
    ├─ linux/amd64                             828f4f57525d           0B             0B
    ├─ linux/arm/v6                            563c0b58e54b           0B             0B
    ├─ linux/arm/v7                            6045d4846c59           0B             0B
    └─ linux/arm64/v8                          11e8dfd68841        276MB         69.8MB

    alpine:latest                              a8560b36e8b8       12.8MB         3.99MB    U
    ├─ linux/amd64                             1c4eef651f65           0B             0B
    ├─ linux/arm/v6                            903bfe2ae994           0B             0B
    ├─ linux/arm/v7                            9c2d245b3c01           0B             0B
    ├─ linux/arm64/v8                          757d680068d7       12.8MB         3.99MB    U
    ├─ linux/386                               2436f2b3b7d2           0B             0B
    ├─ linux/ppc64le                           9ed53fd3b831           0B             0B
    ├─ linux/riscv64                           1de5eb4a9a67           0B             0B
    └─ linux/s390x                             fe0dcdd1f783           0B             0B

    <untagged>                                 c6c1bcb0fd8d       12.8MB         3.99MB
    └─ linux/arm64                             cb171c618ae8       12.8MB         3.99MB

    <untagged>                                 7361ef970703       12.8MB         3.99MB
    └─ linux/arm64                             07033f43e44a       12.8MB         3.99MB

    <untagged>                                 0c62c63b81ec       12.8MB         3.99MB
    └─ linux/arm64                             94742272117f       12.8MB         3.99MB

    <untagged>                                 91dd947eebd0       12.8MB         3.99MB
    └─ linux/arm64                             ee55d203e26f       12.8MB         3.99MB

    <untagged>                                 382d9f57e8d8       12.8MB         3.99MB
    └─ linux/arm64                             5256d47804e3       12.8MB         3.99MB

    <untagged>                                 56fa17d2a7e7       12.8MB         3.99MB
    ├─ linux/amd64                             483f502c0e6a           0B             0B
    ├─ linux/arm/v6                            c79529000bdf           0B             0B
    ├─ linux/arm/v7                            cc455d4b2c47           0B             0B
    ├─ linux/arm64/v8                          508c1b94e1d2       12.8MB         3.99MB
    ├─ linux/386                               f32403957113           0B             0B
    ├─ linux/ppc64le                           23dbce23b88f           0B             0B
    ├─ linux/riscv64                           f9d2da150cee           0B             0B
    └─ linux/s390x                             6bb03952a007           0B             0B

After this patch

    docker image ls --tree
                                                                           i Info →   U  In Use

    IMAGE                                      ID             DISK USAGE   CONTENT SIZE   EXTRA
    docker:cli                                 28fb556c1ea1        276MB         69.8MB
    ├─ linux/amd64                             828f4f57525d           0B             0B
    ├─ linux/arm/v6                            563c0b58e54b           0B             0B
    ├─ linux/arm/v7                            6045d4846c59           0B             0B
    └─ linux/arm64/v8                          11e8dfd68841        276MB         69.8MB

    alpine:latest                              a8560b36e8b8       12.8MB         3.99MB    U
    ├─ linux/amd64                             1c4eef651f65           0B             0B
    ├─ linux/arm/v6                            903bfe2ae994           0B             0B
    ├─ linux/arm/v7                            9c2d245b3c01           0B             0B
    ├─ linux/arm64/v8                          757d680068d7       12.8MB         3.99MB    U
    ├─ linux/386                               2436f2b3b7d2           0B             0B
    ├─ linux/ppc64le                           9ed53fd3b831           0B             0B
    ├─ linux/riscv64                           1de5eb4a9a67           0B             0B
    └─ linux/s390x                             fe0dcdd1f783           0B             0B

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 14:58:23 +02:00
1a950db5ce cli/command/image: Fix total content size calculation in image tree
Before this patch, image total content size would only include
container images content size.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-11 13:30:20 +02:00
e578f156c0 Merge pull request #5998 from thaJeztah/lazy_regexp
use lazyregexp to compile regexes on first use
2025-04-11 12:29:53 +02:00
b37d84fd10 cli/command: move prompt utilities to separate package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 12:23:16 +02:00
a16c3a49c8 cli/command/image: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:25 +02:00
d47d2338b7 image save: implement file-write with atomicwriter
Same functionality, but implemented with atomicwriter. There's a slight
difference in error-messages produced (but can be adjusted if we want).

Before:

    docker image save -o ./no/such/foo busybox:latest
    failed to save image: invalid output path: directory "no/such" does not exist

    docker image save -o /no/permissions busybox:latest
    failed to save image: stat /no/permissions: permission denied

After:

    docker image save -o ./no/such/foo busybox:latest
    failed to save image: invalid file path: stat no/such: no such file or directory

    docker image save -o /no/permissions busybox:latest
    failed to save image: failed to stat output path: lstat /no/permissions: permission denied

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 09:46:05 +02:00
342a01a9ff migrate to use github.com/moby/go-archive
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 13:18:58 +02:00
2328745f92 cli/command/image: deprecate RunPull and make internal
This function was exported in 812f113685
for use in other parts of the CLI, but it's now only used locally.

Make it internal again, as it was never designed to be exported. There
are no known external consumers of this function, but deprecating it
first, in case there are.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-01 09:33:04 +02:00
b557e37a49 cli/command/image: un-export RunSave
This function was exported in e43c7920ea
for use of "docker app", which is now deprecated. The signature of this
function also depended on a non-exported type, so it could not be used
externally.

Make it internal again, as it was never designed to be exported. There
are no known external consumers of this function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-01 09:32:58 +02:00
9b2479dca7 cli/command/image: un-export RunPush
This function was exported in e43c7920ea
for use of "docker app", which is now deprecated. The signature of this
function also depended on a non-exported type so it could not be used
externally.

Make it internal again, as it was never designed to be exported. There
are no known external consumers of this function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-01 09:31:57 +02:00
4541df21e5 cli/command/image: remove deprecated TagTrusted
This function was only used internally, and has no known external consumers.
It was deprecated in e37d814ce96b01393a400c081666ea1cca2eb8bd; this commit
removes it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-20 11:11:39 +01:00
eaf98b2202 cli/command/image: remove deprecated PushTrustedReference
This function was only used internally, and has no known external consumers.
It was deprecated in d80436021c21c26b492f0014511f13f41d8b42d9; this commit
removes it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-20 11:11:39 +01:00
98d0b0cc14 cli/command/image: remove deprecated TrustedPush
This function was only used by "docker trust sign", and has no known external
consumers. It was deprecated in c6f456bc90574f4180f3b990e8a4e216485e35b7;
this commit removes it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-20 11:11:39 +01:00
bb0e9adbc0 remove redundant error-handling for registry.ParseRepositoryInfo
Since [moby@c2c3d59], [registry.ParseRepositoryInfo] now always returns
a nil error, so we can remove the error handling.

[registry.ParseRepositoryInfo]: 5f0d6731eb/registry/config.go (L414-L443)
[moby@c2c3d59]: c2c3d593cf

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-19 13:55:38 +01:00
879acd15ff Merge pull request #5911 from thaJeztah/builder_nits
cli/command/image: fix some minor linting issues
2025-03-10 16:12:24 +01:00
802d8e801a image load: combine checks to a single switch
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 14:43:57 +01:00
2c0f9f476d cli/command/image: explicitly ignore some unhandled errs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-08 22:47:56 +01:00
e73fb7d2f6 cli/command/image: rename var that shadowed type
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-08 22:43:21 +01:00
e37d814ce9 cli/command/image: deprecate TagTrusted, move to cli/trust
This function was shared between "image" and "container" packages,
all of which needed the trust package, so move it there instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 21:36:53 +01:00
d80436021c cli/command/image: deprecate PushTrustedReference, move to trust
This function was shared between "trust" "image" and "plugin" packages,
all of which needed the trust package, so move it there instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 18:29:12 +01:00
c6f456bc90 cli/command/image: deprecate and internalize TrustedPush
This function was only used by "docker trust sign"; inline the code
and deprecate the function.

This function has no known external consumers, so we should remove
it on the first possible ocassion (which could be a minor release).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 18:29:08 +01:00
2793731977 cli/command: internalize constructing Notary client
The CLI.NotaryClient method is a shallow wrapper around trust.GetNotaryRepository
and only depends on the CLI itself to pass its StdErr/StrOut streams.

- This patch inlines the code to produce the client, skipping the wrapper.
- Define a local interface for some tests where a dummy notary client was used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 17:40:06 +01:00
c7072a885d cli/command/image: rename vars that shadowed type
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:38 +01:00
7a6270d190 cli/command/image: move AddTargetToAllSignableRoles to cli/trust
This utility was shared between the "image" and "trust" packages, and a
shallow wrapper around features in the cli/trust package. Move it there
instead and rename it to `trust.AddToAllSignableRoles`.

There are no known external consumers of this utility, so skipping a
deprecation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:38 +01:00
e6382db10e cli/command/image: move trust unit-tests to trust package
These tests were not testing functionality that was implemented
in the image package. Move them to the trust package, where
they belong.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:37 +01:00
55bc30a784 cli/command/image: use t.SetEnv in trust tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:37 +01:00
049f84c94d cli/command/image: remove TestAddTargetToAllSignableRolesError
This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the [TestGetSignableRolesError]
test in the cli/trust package.

[TestGetSignableRolesError]: fe0a8d2791/cli/trust/trust_test.go (L49-L55)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:37 +01:00
2b169c1ab5 golangci-lint: enable revive "line-length-limit" linter
also disable "lll" linter as it did the same.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-17 15:24:58 +01:00
3e44cc4d00 cli/command/image: fix "unused-receiver", "line-length-limit" linting
cli/command/image/remove_test.go:24:7: unused-receiver: method receiver 'n' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (n notFound) NotFound() {}
          ^
    cli/command/image/formatter_history_test.go:110: line-length-limit: line is 558 characters, out of limit 200 (revive)
        withTabs := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80	--recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62	&& echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list  && apt-get update  && apt-get install --no-install-recommends --no-install-suggests -y       ca-certificates       nginx=${NGINX_VERSION}       nginx-module-xslt       nginx-module-geoip       nginx-module-image-filter       nginx-module-perl       nginx-module-njs       gettext-base  && rm -rf /var/lib/apt/lists/*` //nolint:lll
    cli/command/image/formatter_history_test.go:111: line-length-limit: line is 552 characters, out of limit 200 (revive)
        expected := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list  && apt-get update  && apt-get install --no-install-recommends --no-install-suggests -y       ca-certificates       nginx=${NGINX_VERSION}       nginx-module-xslt       nginx-module-geoip       nginx-module-image-filter       nginx-module-perl       nginx-module-njs       gettext-base  && rm -rf /var/lib/apt/lists/*` //nolint:lll

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-17 15:24:56 +01:00
1d3eb6f95b vendor: github.com/docker/docker 5cc3f1dab895 (master, v28.0.0-rc.2)
full diff: b570831cc3...5cc3f1dab8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-14 19:22:53 +01:00
a656dfd409 Restrict completion for some commands with a limit paramter for ImageNames
Previously, multiple suggestions were provided when completing
commands like `run`, `history` and `push`. This change
limits completion to a single suggestion for the above and 2 suggestions for `tag`

Signed-off-by: Mohammed Aminu Futa <mohammedfuta2000@gmail.com>
2025-02-12 12:42:19 +00:00
01da8a582f vendor: github.com/docker/docker 6c3797923dcb (master, v28.0-dev)
full diff: 6968719093...6c3797923d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-06 19:16:50 +01:00
dff0dc8afa Merge pull request #5790 from thaJeztah/leftover_cleanups
cli/command: some minor cleanups
2025-02-04 12:30:30 +00:00
7c3fa8172b Merge pull request #5791 from thaJeztah/multi_errors
cli/command: use errors.Join instead of our own implementation
2025-02-04 12:23:11 +01:00
5b90e0e4e5 Merge pull request #5744 from vvoland/image-tree-chips
image/tree: Chips to represent "in use"
2025-02-04 09:23:24 +00:00
7147e85f63 cli/command/image: use errors.Join
Use stdlib multi-errors instead of creating our own

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-03 19:20:34 +01:00
632f179e8f cli/command/image: minor cleanups
- use apiClient instead of client for the API client to
  prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-03 19:08:08 +01:00
c950d48f72 image/tree: Chips to represent "in use"
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-03 18:24:32 +01:00
c8f27b027f cli/command/image: minor cleanups: use Println, rename vars
- use Println to print newline instead of custom format
- use apiClient instead of client for the API client to
  prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-03 12:18:11 +01:00
f29fdd3091 cli/command/image: remove uses of pkg/errors in tests
While there may be reasons to keep pkg/errors in production code,
we don't need them for these tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-01 15:59:57 +01:00